Ghostscript - getting "pdfsettings=/ebook" into individual arguments?

3.7k views Asked by At

I’m creating pdf's for a RIP-engine. Sometimes I have to convert all fonts to outlines and maybe 1/1000 of those pdfs will get stuck while ripping. For the conversion to outlines I use:

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dNoOutputFonts -sOutputFile outlined_output.pdf input.pdf

When this occures, I previously just opened the pdf in Acrobat and used PitStop to convert to outlines instead, since I thought that the problem was with Ghostscript's way of outlining.

Now, I’ve noticed that if I just open the very same pdf that get stuck while ripping in Acrobat 9 Standard and save it to another location, it will rip just fine.

I then tried a bunch of gs-commands and found out that if I use -dPDFSETTINGS=/screen or /ebook it would rip ok, but not when using /printer or /prepress. For quality reasons, /screen and /ebook is not ok.

I tried to understand what differs from ebook and printer.

/ebook

gs   -q   -dNODISPLAY   -c ".distillersettings /ebook get {exch ==only ( ) print ===} forall quit" | sort

Gives:

/AutoRotatePages /All
/CannotEmbedFontPolicy /Warning
/ColorACSImageDict << /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] /QFactor 0.76 /ColorTransform 1 >>
/ColorConversionStrategy /sRGB
/ColorImageDownsampleType /Average
/ColorImageResolution 150
/CompatibilityLevel 1.5
/CreateJobTicket false
/DoThumbnails false
/EmbedAllFonts true
/GrayACSImageDict << /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] /QFactor 0.76 /ColorTransform 1 >>
/GrayImageDownsampleType /Average
/GrayImageResolution 150
/MonoImageDownsampleType /Subsample
/MonoImageResolution 300
/NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats]
/PreserveEPSInfo false
/PreserveOPIComments false
/PreserveOverprintSettings false
/UCRandBGInfo /Remove

And /printer

gs   -q   -dNODISPLAY   -c ".distillersettings /ebook get {exch ==only ( ) print ===} forall quit" | sort

Gives:

/AutoRotatePages /None
/CannotEmbedFontPolicy /Warning
/ColorACSImageDict << /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] /QFactor 0.4 /ColorTransform 1 >>
/ColorConversionStrategy /UseDeviceIndependentColor
/ColorImageDownsampleType /Average
/ColorImageResolution 300
/CompatibilityLevel 1.7
/CreateJobTicket true
/DoThumbnails false
/EmbedAllFonts true
/GrayACSImageDict << /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] /QFactor 0.4 /ColorTransform 1 >>
/GrayImageDownsampleType /Average
/GrayImageResolution 300
/MonoImageDownsampleType /Subsample
/MonoImageResolution 1200
/NeverEmbed []
/PreserveEPSInfo true
/PreserveOPIComments true
/PreserveOverprintSettings true
/UCRandBGInfo /Preserve

Now, I was thinking if I could take the /ebook settings into command-line arguments and adjust or remove one by one until I find the correct command that makes the pdf rip fine. As I can read from examples on the web, -dAutoRotatePages=/None is a correct argument. Adding "-d" together with "=" looks to be correct? Also, NeverEmbed, ColorACSImageDict and GrayACSImageDict must be called from "-c" (https://www.ghostscript.com/doc/9.22/VectorDevices.htm#note_13)

EDIT: new command based on KenS guidelines:

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite
-dAutoRotatePages=/All \
-dCannotEmbedFontPolicy=/Warning \
-dColorConversionStrategy=/sRGB \
-dColorImageDownsampleType=/Average \
-dColorImageResolution=150 \
-dCompatibilityLevel=1.5 \
-dCreateJobTicket=false \
-dDoThumbnails=false \
-dEmbedAllFonts=true \
-dGrayImageDownsampleType=/Average \
-dGrayImageResolution=150 \
-dMonoImageDownsampleType=/Subsample \
-dMonoImageResolution=300 \
-dPreserveEPSInfo=false \
-dPreserveOPIComments=false \
-dPreserveOverprintSettings=false \
-dUCRandBGInfo=/Remove \
-sOutputFile=final_output.pdf \
-c '<</ColorACSImageDict << /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] /QFactor 0.76 /ColorTransform 1 >>  <</GrayACSImageDict << /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] /QFactor 0.76 /ColorTransform 1 >> <</NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats] >> setdistillerparams' \
-f outlined_output.pdf

This command produces a pdf that still gets stuck. So what am I doing wrong, is the formatting wrong somewhere? How should the arguments look like to be exactly like /ebook?

Anyone have direct suggestions on what the difference could be between /ebook and /printer that can cause the pdf to stuck at the rip?

Best Regards Niclas

1

There are 1 answers

5
KenS On

The PDFSETTINGS are contained in ghostpdl/Resource/Init/gs_pdfwr.ps, so you can see how these are set.

You don't need to (and shouldn't really) put each piece of PostScript in its own -c/-f bracketing. Open PostScript with -c, send the PostScript program you want, and then close it with -f.

Don't use .setpdfwrite, or if you must, don't use it multiple times, that won't be helpful.

My suggestion would be to take the last command line you have there, then remove commands one at a time until your file works. Then you'll know which setting is causing you a problem.

I'd also suggest that once you know that, you open a bug report with a specimen file and command line which exhibits a problem, so that someone can fix it....

For what its worth, this sounds to me like a problem with your PDF consumer though, if Acrobat will open the files which Ghostscript produces without a problem. You might report that to the manufacturer so they can fix their problem too.

[EDIT]

If I understand you correctly, the PDF produced by Ghostscript gets 'stuck' when you send that PDF to 'some other PDF consumer'.

So what you really need to do is identify what exactly it is that the device doesn't like.

I'm assuming that if you use pdfwrite with no parameters (eg gs -sDEVICE=pdfwrite -o out.pdf <input.pdf>) the resulting PDF file works as expected ?

Assuming that it does, and you have a command line (in your edit above) which results in a PDF file which doesn't work, you can remove the switches one by one until you get a file which starts working. Put back the last removed switch and remove the remaining ones one by one. Ideally you should end up with one switch which is causing a problem for your other consumer.

At that point, take the PDFSETTINGS you want and either apply each of the switches individually, or set -dPDFSETTINGS and then turn off the control causing a problem, by setting it after you set PDFSETTINGS.