Convert pdf file with images in jpeg2000 to pdf with non jpeg2000 images

5,893

Solution 1

For those with a Windows PC and no access to a Mac:

  1. Download both GSView and Ghostscript.
  2. Install Ghostscript and then GSView.
  3. Open your PDF in GSView
  4. From the File menu, select Convert.
  5. In the dialog box, under Device, choose PDFWrite, then OK

The resulting output should display properly on iOS devices.

Solution 2

I'm giving this advice with all reservations, since I currently don't have a way to verify it...

However, what I'm sure about: Ghostscript does support JPEG2000 compression of images (but you may need to specifically build it that way; see http://svn.ghostscript.com/ghostscript/trunk/gs/doc/Make.htm).

Now, what I'm not sure about: there is this -dAutoFilterColorImages=... commandline parameter. You may be able to use it like this:

gswin32c.exe ^
    -dBATCH ^
    -dNOPAUSE ^
    -dSAFER ^
    -sDEVICE=pdfwrite ^
    -dAutoFilterColorImages=false ^
    -dUseFlateCompression=true ^
    -sOutputFile=output-pdf-flate.pdf ^
    c:/path/to/input-jpeg2000.pdf

If it works as I think it does, a JPEG2000-enabled Ghostscript build would read your problematic PDF in without error, and write the output PDF with pictures using flate compression instead of JPEG2000.


UPDATE: Found out some additional pieces of info.

  1. Recent Ghostscript releases (current is 8.71) are JPEG2000-enabled by default.
  2. 'JPEG2000-enabled' means: 'can read and process JPEG2000 in input PDF'.
  3. Ghostscript does not write JPEG2000 to its output PDF [*].

[*] Reason: There is no support for creating JPEG2000 images, because the encoder costs money to licence (and it is patent encumbered, so it is risky to write an own implementation).

This means you should not even need to add the -dAutoFilterColorImages=... and -dUseFlateCompression=... parameters to the commandline. A simple re-distillation of the PDF should work:

gswin32c .... -sDEVICE=pdfwrite -sOutputFile=out.pdf input.pdf

Update 2:

Share:
5,893
Tony_Henrich
Author by

Tony_Henrich

Updated on September 17, 2022

Comments

  • Tony_Henrich
    Tony_Henrich almost 2 years

    I have a pdf file which has images compressed using jpeg2000 compression. The iPad can't display these images in the pdf. Is there a free utility to convert the pdf file to a pdf version where all the images do not use jpeg2000 compression? Looking for a quick solution as in open pdf file, change some setting, save as ..

    • Kurt Pfeifle
      Kurt Pfeifle almost 13 years
      So? Did my answer work out for you?
  • Tony_Henrich
    Tony_Henrich almost 14 years
    I downloaded gswin32c.exe from the web but I get an error about unable to load a dll. Are there any dependencies? I don't have the tools to compile this tool. Is the full tool available for download?
  • Kurt Pfeifle
    Kurt Pfeifle almost 14 years
    Downloading the gswin32c.exe is not enough. You need all the accompanying resources as well (plus, the .dll). Everything is here in the gs871w??.exe(s): ghostscript.com/releases (scroll down).
  • Kurt Pfeifle
    Kurt Pfeifle almost 13 years
    @Tony_Henrich: did downloading and installing the gs871w??.exe (instead of the single gswin32c.exe work for you?
  • AnNaSF
    AnNaSF almost 13 years
    The issue that I have is that, this works, but it seems to keep cutting off the text. If I use 72dpi conversion it gets most of it, but still cuts off about an inch off the right side. I'm looking through their help, but any other help would be appreciated.