1

I have (3 pretty large) PDF files which I obtain using ghostscript from a single source pdf generated with xelatex (both under ubuntu linux). The 3 files select different regions from the source, like so

gs -o out.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=26562 -dDEVICEHEIGHTPOINTS=4252 -dFIXEDMEDIA -dCompatibilityLevel=1.4 -dEmbedAllFonts=true -c "<</PageOffset [-7447 0]>> setpagedevice" -f in.pdf

Only the PageOffset and the dimensions differ for the three files.

The last two files, which do not start at the origin, however do not display correctly in adobe acrobat reader DC (tested under windows). They do display in all other PDF-viewers I tried, but I need to submit them to a print service which does not seem to be able to deal with the problem.

What can I try to fix the files (I tried pdf fix utilities under Ubuntu, but that did not work)?

2 Answers 2

1

This problem can circumvented by reducing the media size of the document. Adobe Acrobat seems not to be able to display documents if the dimensions are too large (while other viewers might be).

Try running

gs -o out_a.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=[half-width] -dDEVICEHEIGHTPOINTS=[half-height] -dPDFFitPage -dCompatibilityLevel=1.4 -dEmbedAllFonts=true -dDownsampleColorImages=false -dDownsampleGrayImages=false -dDownsampleMonoImages=false -f out.pdf

with [half-height] and [half-width] half the previous values and out.pdf the output of your initial ghostscript command.

If it still does not work, you may want to try even smaller values.

4
  • There is (or at least used to be) an implementation limit of 200 x 200 in for the media box in Acrobat/Reader.
    – Max Wyss
    Mar 18, 2016 at 10:06
  • In the present case this would not be sufficient. The problem appeared at over 200 in which other viewers seem to support without a problem. If that's a known limitation of Acrobat, I need to add the negative point that it does not issue a warning message of any kind.
    – highsciguy
    Mar 18, 2016 at 15:15
  • In case that the documents are essentially raster images, increasing the resolution would help.
    – Max Wyss
    Mar 19, 2016 at 8:03
  • No, they are mostly vector. Changing the resolution did not help. Also not changing the compatibility level, image compression and other ghostscript options that have been tried.
    – highsciguy
    Mar 19, 2016 at 16:38
0

I just had this problem where Acrobat shows a blank PDF accompanied with the error "Insufficient data for an image". The PDFs in question were produced by libtiff. This solution will only work for libtiff-produced PDFs.

In this case libtiff used a 24-bit colour profile but said the image was only 1-bit (monochrome), and both Acrobat and Ghostscript preferred the colour profile's bit depth (so couldn't open the file), while other PDF readers preferred the file's overridden bit depth (and would show the file just fine).

In my case the fix was to change the PDF file to use a different colour profile, which meant doing a binary replace of this text:

/ColorSpace [/ICCBased 7 0 R]

with this text:

/ColorSpace /DeviceGray %0 R]

The % starts a comment ignoring the rest of the data on that line, which is required so the offsets of subsequent data does not change. As I am on Linux, I made the change with sed:

sed -i 's|/ColorSpace \[/ICCBased 7 0 R\]|/ColorSpace /DeviceGray %0 R]|' file.pdf

This fix was suggested by the fine folks over at the Ghostscript project and got all my broken PDFs working again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.