If setpagedevice and setdistillerparams are called (in this order) after gsave, then the corresponding grestore will restore the distiller parameters (and it shoudn't). The PostScript fragment at the end of this bug report shows the problem (it also shows the problem in bug #687271). Note: The root cause for the wrong behaviour of distiller parameters (bugs #563287, #607425, #687271, and this one) is that these parameters are not, but are implemented as, page device parameters. On the other hand, I agree that managing these parameters at the device level is more elegant (read: object-oriented), especially given the large number of very different drivers in GhostScript. I also agree that the interface used by setpagedevice may be used to let the driver know of distiller parameters changes. ------- %!PS false setglobal /crlf { ( ) print } def /buf10 10 string def /wr10 { % val -- ( ) buf10 copy pop buf10 cvs pop buf10 print } def /maxindent ( ) def /i 0 def /i++ { /i i 2 add store } def /i-- { /i i 2 sub store } def /crtval null def /setval { % msg newval -- () wr10 dup wr10 i 0 gt { maxindent 0 i getinterval print} if exch print crlf /crtval 1 index store 1 dict dup /AutoFilterColorImages 4 -1 roll put setdistillerparams } def /prtval { % msg -- crtval wr10 currentdistillerparams /AutoFilterColorImages get wr10 i 0 gt {maxindent 0 i getinterval print} if print crlf } def a4 (expected) wr10 (found) wr10 (message) print crlf (--------) wr10 (--------) wr10 (----------------------------------------) print crlf (Will "save" ...) false setval save i++ (... did "save") prtval 0 0 moveto 612 792 lineto stroke (Will "gsave" ...) true setval gsave i++ (... did "gsave", will "setpagedevice" ...) prtval <</PageSize [100 100]>> setpagedevice (... did "setpagedevice") prtval (Changing value after save-gsave-setpagedevice) false setval i-- grestore (... did "grestore", will "setpagedevice" again ...) prtval <</PageSize [50 100]>> setpagedevice (... did "setpagedevice", preparing to "restore"...) true setval i-- restore (... did "restore") prtval showpage -------
I get Error: /undefined in /setdistillerparams with the test sample, but I recall have reproduced this at one time and/or discussing it on the call. Assigning to Ray for further investigation.
Distiller-related operators are visible only when the current device is pdfwrite ("where" is patched to check the current device and hide them if necessary). With other devices, the error mentioned in comment #1 is normal.
I have verified that this situation still occurs in the latest build (r8191). The output I see when I run this with the following arguments: gs -sDEVICE=pdfwrite -sOutputFile=test.pdf -r72 687280.ps (where 687280.ps is the PS from comment #0) is as follows: expectedfound message -------------------------------------------------------- false Will "save" ... false false ... did "save" true Will "gsave" ... true true ... did "gsave", will "setpagedevice" ... true true ... did "setpagedevice" false Changing value after save-gsave-setpagedevice false true ... did "grestore", will "setpagedevice" again ... true ... did "setpagedevice", preparing to "restore"... false true ... did "restore"
Bug still reproducible in Ghostscript 9.03
See bug #687271 Closing as wontfix because frankly its been 9 years, nobody has done anything about this, and its yet to present an actual problem.