title: Script to search for text from PDF
body: <h3>Problem</h3>
  
  <p>On the Mac OS X platform, I would like to write a script, either in Python or Tcl to search for text within a PDF file and extract the relevant parts. I appreciate any help.</p>
  
  <h3>Background</h3>
  
  <p>I am writing scripts to look inside a PDF to determine if it is a bill, from what company, and for what period. Based on these information, I rename the PDF and move it to an appropriate directory. For example, file such as <code>Statement_03948293929384.pdf</code> might become <code>2012-07-15 Water Bill.pdf</code> and moved to my <code>Utilities</code> folder.</p>
  
  <h3>What have I done so far?</h3>
  
  <ul>
  <li>I have searched for PDF-to-plain-text tools, but not found anything yet</li>
  <li>I have looked into the Tcl wiki and found an example, but could not get it to work (I searched for text in PDF, but not found).</li>
  <li>I am looking into <code>pdf-parser.py</code> by Didier Stevens</li>
  <li>I heard of a Python package called pyPdf and will look at it next.</li>
  </ul>
  
  <h3>Update</h3>
  
  <p>I have found a command-line tool called <a href="http://www.bluem.net/en/mac/packages/" rel="nofollow">pdftotext</a> written by Glyph &amp; Cog, LLC; built and packaged by <a href="http://www.bluem.net/" rel="nofollow">Carsten Bluem</a>. This tool is straight forward and it solves my problem. I am still looking out for those tools that can search PDF directly, without having to convert to text file.</p>