i have a postscript file, which has heavily printer driver setting dependencies. I am trying to bundle printer settings into my postscript printfile and passthrough it to the printer. The passthrough works just fine with `lpr -l . But i am not able to bring some options from the ppd directly into the postscript file.
Xerox pdd file snipped
*OpenUI *OutputMode/Print Quality: PickOne
*OrderDependency: 46.0 AnySetup *OutputMode
*DefaultOutputMode: HighSpeed
*OutputMode HighSpeed/High Speed: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (high-speed) put
>> setpagedevice
"
*End
*OutputMode HighQuality/High Quality: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-quality) put
>> setpagedevice
"
*End
*OutputMode HighResolution/High Resolution: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-resolution) put
>> setpagedevice
"
*End
*CloseUI: *OutputMode
When i place the highest-resolution part at the beginning of the %%BeginPrelog part, than i get an invalid file:
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-resolution) put
>> setpagedevice
When i evaluate the correctness of the file via ps2pdf i get the following error:
Error: /undefined in --get--
Operand stack:
--nostringval-- PostRenderingEnhance true PostRenderingEnhanceDetails --dict:210/309(ro)(L)-- PostRenderingEnhanceDetails
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1990 1 3 %oparray_pop 1989 1 3 %oparray_pop 1977 1 3 %oparray_pop 1833 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:731/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Current file position is 308
GPL Ghostscript 9.50: Unrecoverable error, exit code 1
Nevertheless, the setpagedevice options from this post works just fine: How to select PostScript printer output tray
So i do not know how to convert the ppd option to valid postscript code. Does anyone have a clue here, how to get a valid postscript file?
You are trying to apply a device-specific control (/OutputMode) to a device which does not support that control. Not only that, but the code you include acesses the current page device dictionary and assumes that there will be a PostRenderingEnhanceDetails dictionary in it. The code makes no attempt to check if the required data exists which means it will only work on a device which has a /PostRenderingEnhanceDetails entry in the page device dictionary. The pdfwrite device (which is what ps2pdf uses) does not have such an entry, which is why you get an error.
There may be nothing wrong with your PostScript, its simply that you can't apply it to that device. Note that all the keys in the question you link to are standard page device dictionary entries, OutputMode is not and there is no PostRenderingEnhanceDetails entry either.
The PostScript code in the PPD (PostScript Printer Description) is all that you need to use, but the opint of a PPD is to include PostScript that will only work reliably on the printer its intended for. You can't use Ghostscript to test the correctness of device-specific PostScript configured for a non-Ghostscript device.