Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whole PDF compression

Tags:

pdf

I'm working on a tool that will be writing PDFs and am trying to find a way to compress the objects and streams in the PDF. A number of the PDFs that I'm generating are fairly large, but can be substantially reduced by compressing the objects (or most of the PDF structure) into a flate stream. I swear I've seen this done before, but none of the PDFs that I've looked at seem to do it. I also tried using Acrobat X to compress it with "entire file compression", but it seems to only compress the streams.

I've tried using ObjStm, but it doesn't have a lot of support from other file readers. I need something that has a little more support outside of Adobe.

Any suggestions are appreciated!

like image 424
JKS Avatar asked Oct 11 '22 16:10

JKS


1 Answers

In PDF you can have 2 types of compression:

  1. stream compression - the data is compressed using various methods, but the PDF file structure is not compressed.
  2. object compression - you also compress the file structure, mainly the objects that do not include streams.

These are the only supported compression scenarios in PDF. Selecting the right compression method depends much on the data you want to compress: for page content streams usually Flate compression is used, 1bpp images use CCITT G4 or better JBIG2, color images are better compressed with JPEG2000, etc.

Object compression is available since Acrobat 6.

like image 147
iPDFdev Avatar answered Oct 18 '22 03:10

iPDFdev