ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

my $pdf = PDF::API2->open( $keyhash->{filename} ) FAILS when PDF is protected #48

Closed DavidAyliffe closed 2 years ago

DavidAyliffe commented 2 years ago

Rosenshine.pdf

When I try to open the attached file, my code crashes with this error:

Uncaught exception from user code: Objind 163 does not exist at index 0 at /Library/Perl/5.30/PDF/API2/Basic/PDF/File.pm line 783. PDF::API2::Basic::PDF::File::read_objnum(PDF::API2::Basic::PDF::File=HASH(0x12ebded98), 163, 0) called at /Library/Perl/5.30/PDF/API2/Basic/PDF/File.pm line 737 PDF::API2::Basic::PDF::File::read_obj(PDF::API2::Basic::PDF::File=HASH(0x12ebded98), PDF::API2::Basic::PDF::Objind=HASH(0x12f818f98)) called at /Library/Perl/5.30/PDF/API2/Basic/PDF/Objind.pm line 155 PDF::API2::Basic::PDF::Objind::realise(PDF::API2::Basic::PDF::Objind=HASH(0x12f818f98)) called at /Library/Perl/5.30/PDF/API2.pm line 179 PDF::API2::_open_common(PDF::API2=HASH(0x12ebdedc8)) called at /Library/Perl/5.30/PDF/API2.pm line 166 PDF::API2::open("PDF::API2", "LP/Rosenshine.pdf") called at AnalyseIMSCCv2.17.pl line 2357 main::GetPDFMetadata(HASH(0x12f48aec0)) called at AnalyseIMSCCv2.17.pl line 5463 main::ProcessItems() called at AnalyseIMSCCv2.17.pl line 770

ssimms commented 2 years ago

Yes, PDF::API2 doesn't support encrypted PDFs. I haven't used it, but CAM::PDF might be an option for you.