Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PDF::API2 support reading PDF 1.5+ with compressed XRef?

Tags:

pdf

perl

It appears that PDF::API2 does not support PDF 1.5 (and later) compression of the xref table. This type of file is more common since Acrobat 9 & 10 write them by default. The other compression scheme is compressed object streams.

I get the following error: Malformed xref in PDF file at /opt/local/lib/perl5/site_perl/5.12.3/PDF/API2/Basic/PDF/File.pm line 1140.

Do any of the Perl PDF modules support reading a PDF with a compressed XRef?

like image 887
Dwight Kelly Avatar asked Jul 23 '11 14:07

Dwight Kelly


1 Answers

CAM::PDF can read a compressed XRef. The documentation says:

The file format through PDF 1.5 is well-supported, with the exception of the "linearized" or "optimized" output format, which this module can read but not write.

I haven't worked with CAM::PDF. But I looked it over and the api feels strange after coming from PDF::API2. It is more low level or something. There are advantages and disadvantages to both libraries though.

We use PDF::API2 at work and ask our designers to save as PDF v1.4 when they give us stuff. You can also use ghostscript to convert them to PDF 1.4 which is supported by PDF::API2.

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -o out.pdf in.pdf
like image 163
Eric Johnson Avatar answered Sep 30 '22 14:09

Eric Johnson