title: Python - convert pdf to text, encoding error
body: <p>I tried to convert pdf document to txt file.
  (example of pdf file <a href="http://www.iscramlive.org/ISCRAM2014/papers/p18.pdf" rel="nofollow">link</a>)</p>
  
  <p>So I tried like below.
  But the extracted text is strange like <code>??챘#?遏?h첨챦_철?‾n?~w??¬?k</code>
  How can I fix it?</p>
  
  <pre><code>#!/usr/bin/python
  # -*- coding: cp949 -*-
  # -*- coding: utf-8 -*-
  # -*- coding: latin-1 -*-
  # -*- coding: euc-kr -*-
  
  import codecs
  import pyPdf
  filename = "d:/data/processed_data/paper/iscram/2006/iscram1.pdf"
  #pdf = codecs.open(filename, "rb", encoding = 'utf-8') 
  pdf = codecs.open(filename, "rb", encoding = 'latin1')
  for page in pdf:
      print page.encode('utf-8')
  </code></pre>
  
  <p>I use a win7-64bit korean version.</p>
  
  <p>I tried it to another way by using pyPdf like below</p>
  
  <pre><code>import os
  import glob
  from pyPdf import PdfFileReader
  import pdfminer
  
  f=open("d:/data/processed_data/paper/iscram/2006/iscram1.txt",'w')
  parent = "d:/data/processed_data/paper/iscram/2006"
  os.chdir(parent)
  filename = os.path.abspath('iscram1.pdf')
  
  input = PdfFileReader(file(filename, "rb"))
  for page in input.pages:
      f.write(page.extractText())
  </code></pre>
  
  <p>but it doesn't work and it occurs ''ascii' codec can't encode character u'\u0152' in position 602: ordinal not in range(128)' error</p>