title: UnicodeEncodeError when reading pdf with pyPdf
body: <p>Guys i had posted a question earlier <a href="https://stackoverflow.com/questions/3854963/pypdf-python-tool">pypdf python tool</a>  .dont mark this as duplicate as i get this error indicated below</p>
  
  <pre><code>  import sys
    import pyPdf
  
    def convertPdf2String(path):
        content = ""
        # load PDF file
        pdf = pyPdf.PdfFileReader(file(path, "rb"))
        # iterate pages
        for i in range(0, pdf.getNumPages()):
            # extract the text from each page
            content += pdf.getPage(i).extractText() + " \n"
        # collapse whitespaces
        content = u" ".join(content.replace(u"\xa0", u" ").strip().split())
        return content
  
    # convert contents of a PDF file and store retult to TXT file
    f = open('a.txt','w+')
    f.write(convertPdf2String(sys.argv[1]))
    f.close()
  
    # or print contents to the standard out stream
    print convertPdf2String("/home/tom/Desktop/Hindi_Book.pdf").encode("ascii", "xmlcharrefreplace")
  </code></pre>
  
  <p>I get this error for a the 1st pdf file
          <code>UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)</code>
   and the following error for this pdf <a href="http://www.envis-icpe.com/pointcounterpointbook/Hindi_Book.pdf" rel="nofollow noreferrer">http://www.envis-icpe.com/pointcounterpointbook/Hindi_Book.pdf</a></p>
  
  <p><code>UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position 38: ordinal not in range(128)</code></p>
  
  <p>How to resolve this</p>