Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am using CAM::PDF to loop page by page through a PDF document looking to exclude the PDF based on existence of one of a set of specific phrases. Many PDFs give no trouble. However, recently I encountered several PDFs where the following error occurs and halts my script:

"DecodeParms must be a dictionary"

Here is the PDF scan section of my code:

my $pdf = CAM::PDF->new($path_to_temp . $title);# Init an object my $pages = $pdf->numPages; # get pages to search $ii = 1; # init the index to PDF pages while ($ii < $pages) { # loop while more pages $PageText = $pdf->getPageText($ii); # get the current page text # Begin to test for skip conditions $ix = 0; # index into phrases to exclude # start a while loop for each exclude while ( $ix < $ExcludCnt) { # start the loop while more phrases $phrase = $Exclud[$ix]; # move the phrase to a variable chomp $phrase; # remove the new line character if ($PageText =~ /$phrase/i ) { # test the current phrase on the + current page print " found ", $phrase; # found a phrase $skip = 1; # set to skip the url $orgcnt++; # update a counter last; # end the phrase loop } # end the if page text } # end the while more phrases continue { # continue to next exclude phrase $ix++; # increment the phrase index } # end the continue next exclude last if $skip == 1; # end the pdf page loop } # end while PDF pages continue { $ii++ ; # get the next PDF page and do it again }

I am wondering if this is bug or a PDF version issue.

Replies are listed 'Best First'.
Re: CAM::PDF Error
by Anonymous Monk on Jun 08, 2013 at 01:30 UTC

    I am wondering if this is bug or a PDF version issue.

    Most likely a PDF version issue, although I wouldn't rule out bug -- send a copy of the pdf (or a smaller one with same problem ) to the author, to rt://CAM-PDF