Bug 695600 - unable to suppress warnings on 9.15
Summary: unable to suppress warnings on 9.15
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.15
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-15 06:14 UTC by majdijr
Modified: 2015-01-11 03:12 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description majdijr 2014-10-15 06:14:19 UTC
I'm trying to execute the following command and according to the documentation (-q) parameter should silence/suppress the warnings and outputs but that's not the case:

gs -sstdout=%stderr -sDEVICE=pdfwrite -dMaxSubsetPct=100 -dAutoRotatePages=/None -dPDFSETTINGS=/ebook -dColorImageDownsampleThreshold=1.4 -dColorImageResolution=128 -dDetectDuplicateImages=true -dMaxInlineImageSize=0 -dColorConversionStrategy=/LeaveColorUnchanged -dDOPDFMARKS -dUseTrimBox -q sOutputFile=\"SOURCE_FILE_PATH" -dNOPAUSE -dNOGC -dBATCH -dNumRenderingThreads=8 -c 50000000 setvmthreshold -f \"OUTPUT_FILE_PATH\


I also tried -dQUIET and -sstdout=%stderr but none of them is working.
How can i stop all those warnings ?
I looked everywhere in the documentation but couldn't find an answer.

Thank you in advance.
Comment 1 Ken Sharp 2014-10-15 06:30:41 UTC
You haven't supplied an example file to look at, nor quoted the warnings, nor explained why this is a problem. Without an example file to look at I can't even tell if the warnings are emitted by the pdfwrite device or by some other component.

Not all warnings can be suppressed in any event, also the documentation does *NOT* say that -q should silence/suppress warnings, it says:

-q
    Quiet startup: suppress normal startup messages, and also do the equivalent of -dQUIET. 

-dQUIET
    Suppresses routine information comments on standard output.

Many warnings are not considered to be 'routine', particularly not from the pdfwrite device. Note from the documentation quoted that adding -dQUIET won't do anything if you have already set -q since it has the same effect.

Your command line has several other problems;

-dUseTrimBox only has any effect if the input is a PDF file. It may be, but that's not clear from the information supplied.

-dDOPDFMARKS is not required when the device is pdfwrite (and setting it to false has no effect in this case either)

-dNOGC this is a debugging parameter and should never be used otherwise.

-dNumRenderingThreads=8 NumRenderingThreads only has any effect with a rendering device. pdfwrite, a high level device, does not generally do any renderint (and even if it does, it does not use the display list) so this parameter has no effect when the device is pdfwrite.

-dPDFSETTINGS=/ebook is fairly pointless when you are setting so many parameters manually.
Comment 2 Ray Johnston 2014-10-15 08:13:35 UTC
I noticed a few other possible problems with the command line:
I 
-dColorConversionStrategy=/LeaveColorUnchanged -dDOPDFMARKS -dUseTrimBox -q sOutputFile=\"SOURCE_FILE_PATH" -dNOPAUSE -dNOGC -dBATCH -dNumRenderingThreads=8 -c 50000000 setvmthreshold -f \"OUTPUT_FILE_PATH\

There is no '-' before sOutputFile= and "SOURCE_FILE_PATH" is probably *NOT*
what you want, nor -f \"OUTPUT_FILE_PATH\  (also missing final '"')

Lastly, since you have redirected Ghostscript's stdout to %stderr with
-sstdout=%stderr you can easily collect ALL output and "dump" it to the
null device bya appending 2>/dev/null to the command line.

Closing this as INVALID since the caller has lots of problems pointed out by
Ken and I, and the 2>/dev/null solves it anyway.
Comment 3 Andreas Plank 2015-01-06 05:07:45 UTC
(In reply to majdijr from comment #0)
> I'm trying to execute the following command and according to the
> documentation (-q) parameter should silence/suppress the warnings and
> outputs but that's not the case:

I have the same issue: warnings appear even -q is set. My example comes from a German PDF file

#!/bin/bash
# get pdf
wget "http://www.dgfm-ev.de/sites/default/files/Geschichte%20S%C3%BCmpiossomo%20korrigiert%20gr%C3%B6%C3%9Fere%20Datei.pdf" --output-document="testfile.pdf"
# process by gs
gs -sDEVICE=jpeg -sOutputFile=testfile.jpg -dFirstPage=1 -dLastPage=1 -r150 -dBATCH -dNOPAUSE -q 'testfile.pdf'
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.

Those warnings are printed to stdout and happening so it's not possible to pipe and post-process an image by let's say convert (ImageMagick). It happens so in MediaWiki extension PDFHandler. 

# try to reroute the file directly to post processing hence does not work:
gs -sDEVICE=jpeg -sOutputFile=- -dFirstPage=1 -dLastPage=1 -r150 -dBATCH -dNOPAUSE -q  'testfile.pdf' 2>&1 | /usr/bin/convert -depth 8 -resize 800 - testfile-post-processed.jpg
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501.
convert: no images defined `testfile-post-processed.jpg' @ error/convert.c/ConvertImageCommand/3210

So the issue is not resolved yet, because post-processing seems impossible through re-routing (using pipe character |).

Any solution beside saving an intermediary file?

Thanks, Andreas
Comment 4 Ken Sharp 2015-01-11 03:12:25 UTC
(In reply to Andreas Plank from comment #3)

> So the issue is not resolved yet, because post-processing seems impossible
> through re-routing (using pipe character |).

The bug was closed as 'invalid' because there was no example provided, nor explanation of the problem.

 
> Any solution beside saving an intermediary file?

Realistically, you cannot fully use the pdfwrite device and pipe the output to stdout. Several functions (specifically including linearisation) are unlikely to work reliably if you do this.

Because the PDF format includes a binary cross-reference table (which may not be at the end of the file), as well as some other reasons, it may be necessary for the PDF writer to seek backwards through the file and rewrite data. Clearly that can't be done with piping to stdout.

As I pointed out in comment #1, the documentation does not say that *all* messages can be suppressed, if for no other reason than the fact that any random PostScript program can send information directly to stdout. The PDF interpreter also cannot fully be silenced, as we consider some warnings important enough that they are never suppressed.

In your specific case, the warnings (really errors, but treated as warnings) are emitted by the TrueType font handler, so its nothing to do with the pdfwrite device. Your PDF file contains a damaged (technically invalid) TrueType font. Since this may lead to glyphs not rendering, or rendering incorrectly, you get a warning.

You *can* (with the caveats above about pdfwrite requiring a seekable file) pipe the output to something other than stdout, but if you insist on using stdout, then there is no reliable alternative to using an  intermediate file.

As an example, this PostScript program:

%!PS
(This is a test) == flush
showpage

Will send "This is a test" to stdout.....