I need to read pdf books, which are Turkish stories. I found a library called pyPdf. My test function, which is given below, is incorrectly encoded. I think I need to have a Turkish codec pack. Am I mistaken? if I am wrong, how can I solve this problem, how can I find this Turkish codec pack?
from StringIO import StringIO import pyPdf,os def getPDFContent(path): content = "" num_pages = 10 p = file(path, "rb") pdf = pyPdf.PdfFileReader(p) for i in range(0, num_pages): content += pdf.getPage(i).extractText() + "\n" content = " ".join(content.replace(u"\xa0", " ").strip().split()) return content if __name__ == '__main__': pdfContent = StringIO(getPDFContent(os.path.abspath("adiaylin-aysekulin.pdf")).encode("utf-8", "ignore")) for line in pdfContent: print line.strip() input("Press Enter to continue...")
source share