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.


In reply to CAM::PDF Error by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.