15 Can I query the default settings Ghostscript uses for an output device (such as ‘pdfwrite’ or ‘tiffg4’)?
15.1 Answer
Since Ghostscript is a full-blown PostScript interpreter, you can also send PostScript snippets to it which do not cause the drawing of page elements, but which query it for its internal state.
If you want to know what the default settings of the Display are, when you ask it via gs some.pdf to just display a PDF on screen, you could try this:
Sample command line (Linux, Unix, Mac OS X):
On Windows this becomes:
The result is a list of /SomeName somevalue pairs which describe the settings used for rendering pages to the current screen.
This is so because usually the display is the default device for Ghostscript to send its output to. Now you may notice that you’ll see an empty Ghostscript window pop up, which you’ll have to close…. Ah, how about adding some options to avoid the popup window?
Or, on Windows:
But this will change the query return values, because you (unintentionally) changed the output device settings:
Result:
Compare this to
Result:
So, please avoid this trap. I successfully fell into it a few years ago, and didn’t even notice it for quite a long time…
Now assuming you want to query for the default settings of the PDF writing device, run this one:
You’ll now have all settings for the pdfwrite device in a *.txt file.
And you may repeat that with some other interesting Ghostscript devices and then compare them for all their detailled differences:
It’s rather interesting to compare the settings for, say, the pswrite and ps2write devices like this (and also discover parameters which are available for the one, but not the other device).
One method that gives you a quick overview is to apply the commandline tool sdiff to the two text files:
On my Mac OS X system, this yields the following result (left column: ps2write, right column: pswrite output):
How to interpret this output?
- Lines with param key entries on both halves indicate: there is the same key available for both output devices, but each one uses a different default value.
- Lines with an entry for one half only indicate: this parameter key is unknown to the other output device.
One example is the /GrayImageResolution key: ps2write has this set to 600 by default whereas pswrite uses 150.
Another example is /LanguageLevel: ps2write has set it to 2.0, while pswrite doesn’t know about this setting.
(It produces PostScript language level 1 only).
The third example is /CompressFonts: ps2write will compress fonts by default.
(You could override this, by specifying a different behavior on the commandline and force uncompressed fonts in the PostScript output.)
pswrite does not support this setting at all.
15.2 Update
As you may imagine this is also a great way to compaare different Ghostscript versions, and track how default settings may have changed for different devices in recent releases. This is especially interesting if you want to find out about all the newly implemented color profile and ICC support which is now present in Ghostscript.
Also, to avoid the return of just -dict- for certain key values, use the === instead of == macro. === acts like == but also prints the content of dictionaries.
So here is the example output for the pdfwrite device.
Remember, Ghostscript’s pdfwrite device is meant to provide mostly the same functionality as Adobe Acrobat Distiller (with the additional feature that it does not only accept PostScript as input, but also PDFs, so you can sort of redistill existing PDF files in order to repair, improve or otherwise manipulate them).
Therefore, Ghostscript’s pdfdevice honors most of the setdistillerparams operator which the original Distiller also supports.
This is the command to use:
On my system, this produces the following output. I include it here in full, because this book will also serve as my personal lookup reference for certain info – in this is one I do need quite frequently:
[*] Notes about the above lists:
According to the official Ghostscript documentation, the following settings (which are supported by Adobe Acrobat Distiller) currently on Ghostscript can be set and queried, but setting them does have no effect:
|
You may also want to read the chapter explaining the purpose of Ghostscript dictionaries. |