2

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

Niclas
  • 135
  • 3
  • 13

1 Answers1

2

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.

KenS
  • 30,202
  • 3
  • 34
  • 51
  • The output of gs_pdfwr.ps looks to be the same as I retrieved from my "ebook-retrieval-command" in my post. I've edited my question with new command, but it still gets stuck so I'm guessing that I don't fully understand how to format the PostScript? – Niclas Jan 22 '19 at 07:05
  • KenS: Even with no parameters, it gets stuck, but only ~1/1000 pdfs. If I add "-dNoOutputFonts" together with "-dPDFSETTINGS=/ebook" it works fine. I've tried to mimic/replace /ebook with the full list of parameters that it uses, but with no luck. I'm unsure wether the ps-code between -c and -f is correctly formatted? When I get the mimic to work, I think the rest will be simple. – Niclas Jan 23 '19 at 06:30
  • Well if your PDF consumer won't read the output from pdfwrite with no parameters then your only real route forward is to investigate the differences between a working an non-working PDF file. Your code already does 'mimic' PDFSETTINGS, I can't see any reason why there should be any differences. I can't reasonably investigate your problem because I don't have your output device to test against. – KenS Jan 23 '19 at 09:51
  • Appearently, my command doesn't mimic the /ebook, since /ebook rips ok and my command doesn't. I decided to edit the parameters for /ebook directly in Resource/Init/gs_pdfwr.ps instead and finally found that "/GrayImageResolution" was the one that troubled me. I dont know why the value 150 from /ebook works, but not 300 from /printer. – Niclas Jan 24 '19 at 12:48
  • Can't tell you that, you would have to take it up with the manufacturer of the PDF consumer. – KenS Jan 24 '19 at 15:04