Gary N.
Gary N.

Reputation: 33

Using CAM::PDF For Perl - Can I Read Text From A (v1.7) Password-Protected PDF File?

I noticed the CAM::PDF Perl module is built to read the text from a PDF file. Right now I have CAM::PDF v1.59 installed. I've successfully used it to read text from a (v1.2) PDF file that is not password protected, but when I try to open a (v1.7) password-protected PDF file using this code...

use strict;
use warnings;
use PDF::API2;
use CAM::PDF;
use CAM::PDF::PageText;

my $file = 'C:\Users\gwilliams\Documents\PWS20130517new.pdf';

my $pdf = CAM::PDF->new($file, '-', '-', 's3cretpasswd', fault_tolerant => 1)
  or die "$CAM::PDF::errstr\n";

my $pageone_tree = $pdf->getPageContentTree(1);

print CAM::PDF::PageText->render($pageone_tree);

... I receive the error message:

Invalid xref stream: could not decode objstream 3085

The attributes of the PDF file itself are:

For what it's worth - it looks like the PDF in question was created with Adobe PDFMaker 10.1 for Excel.

What gives? Am I doing this right - or is the PDF incompatible with CAM::PDF?

Sincerely, Confused

Upvotes: 0

Views: 1705

Answers (1)

Chris Dolan
Chris Dolan

Reputation: 8963

I'm the author of CAM::PDF. It's probably an newer PDF feature that CAM::PDF doesn't support. I wrote the encryption support back in PDF 1.2 days and have barely updated it since. So most likely it's not your fault but is a limitation of the library.

Upvotes: 1

Related Questions