Linux PDF / Postscript Optimization

So, I have a reporting system built using Java and iText. PDF templates are created using Scribus. Java code combines data into a document using iText. Then the files are copied to the NFS share, and the BASH script prints them.

I use acroread to convert them to PS, then lpr PS.

FOSS's pdftops app is terribly inefficient.

My main problem is that the PDF created using iText / Scribus is very large. And I recently ran into a problem when acroread pukes due to the fact that it is gaining 4 GB of memory on large (over 300 pages) documents. (Adobe is very slow when updating material to 64 bits).

Now I can use Adobe Reader on Windows and use the Reduce file size option or everything that caused it, and it significantly (> 10x) reduces the PDF size (it deletes a lot of metadata about the form fields, and this appears) and creates a PDF file that basically an image to print. A.

My question is - does anyone know of a good solution / program to run something similar on Linux. Ideally, this would optimize the PDF file, reduce the size and reduce the complexity of the PS, so the printer could print faster, as it now takes about 15-20 seconds of the page to print. A.

+6
optimization linux pdf postscript itext
source share
2 answers
gs \ -dCompatibilityLevel=1.4 \ -dPDFSETTINGS=/screen \ -dNOPAUSE \ -dBATCH \ -sDEVICE=pdfwrite \ -sOutputFile=output.pdf \ input.pdf 

Ghostscript seems to work for most of this problem. Now I have another problem when ghostscript distorts embedded fonts, but I will open a new question for you.

+4
source share

To reduce the size of the PDF file, use pdfsizeopt , the software I am developing. pdfsizeopt runs on Linux, Mac OS X, Windows (and possibly other systems).

pdfsizeopt has many dependencies, so it can be a little cumbersome to install (about 10 minutes of your time). I am working on simplifying the installation.

If you need something fast, you can try one of your dependencies: Multivalent tool.pdf.Compress , which is a pure Java tool.

Get Multivalent20060102.jar , install Java and run

 java -cp Multivalent20060102.jar tool.pdf.Compress input.pdf 

There are restrictions on the way gs -sDEVICE=pdfwrite :

  • it cannot generate xref streams (so the pdf will be bigger than necessary)
  • it cannot generate streams of objects (so PDF will be more than necessary)
  • it does not deduplicate images or other objects (i.e. if the same image appears several times in the input PDF file, gs makes a copy on the output for each case)
  • it reproduces suboptimal images
  • It re-displays low resolution images.
  • it sometimes skips hyperlinks in pdf
  • it cannot convert some constructs (therefore, the output PDF may visually differ from the input)

Neither pdfsizeopt nor the Multivalent tool.pdf.Compress suffers from these restrictions.

+4
source share

All Articles