title: Trouble reading text from a pdf in Perl
body: <p>I am trying to read the text content of a pdf file into a Perl variable. From other SO questions/answers I get the sense that I need to use <code>CAM::PDF</code>. Here's my code:</p>
  
  <pre><code>#!/usr/bin/perl -w
  
  use CAM::PDF;
  my $pdf = CAM::PDF-&gt;new('1950-01-01.pdf');
  print $pdf-&gt;numPages(), " pages\n\n";
  
  my $text = $pdf-&gt;getPageText(1);
  print $text, "\n";
  </code></pre>
  
  <p>I tried running this on <a href="http://www.hawes.com/1950/1950-01-01.pdf" rel="nofollow">this pdf file</a>. There are no errors reported by Perl. The first print statement works; it prints "2 pages" which is the correct number of pages in this document.</p>
  
  <p>The next print statement does not return anything readable. Here's what the output looks like in Emacs:</p>
  
  <pre><code>2 pages
  
  ^A^B^C^D^E^C^F^D^G^H
  ^D^A^K^L^C^M^D^N^C^M^O^D^P^C^Q^Q^C      ^D^R^K^M^O^D ^A^B^C^D^E
  ^F^G^G^H^E
  ^K^L
  ^M^N^E^O^P^E^O^Q^R^S^E
  .... more lines with similar codes ....
  </code></pre>
  
  <p>Is there something I can do to make this work? I don't understand pdf files too well, but I thought that because I can easily copy and paste the text from the PDF file using Acrobat, it must be recognized as text and not an image, so I hoped this meant I could extract it with Perl.</p>
  
  <p>Any guidance would be much appreciated.</p>