小编Abh*_*hra的帖子

我想用 python 抓取印地语(印度语)pdf 文件

我已经编写了从 PDF 文件中抓取所有数据的 python 代码。这里的问题是,一旦被刮掉,单词就会失去语法。如何解决这些问题?我附上代码。

from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from cStringIO import StringIO
def convert_pdf_to_txt(path):
   rsrcmgr = PDFResourceManager()
   retstr = StringIO()
   codec = 'utf-8'
   laparams = LAParams()
   device = TextConverter(rsrcmgr, retstr, codec=codec,laparams=laparams)
   with open(path, 'rb') as fp:
         interpreter = PDFPageInterpreter(rsrcmgr, device)
         password = ""
         caching = True
         pagenos = set()

         for page in PDFPage.get_pages(fp, pagenos, password=password,caching=caching, check_extractable=True):
             interpreter.process_page(page)
         text = retstr.getvalue()
  device.close()
  retstr.close()
  return text
print convert_pdf_to_txt("S24A276P001.pdf") …
Run Code Online (Sandbox Code Playgroud)

python pdf ocr pdf-scraping pdfminer

5
推荐指数
1
解决办法
1436
查看次数

标签 统计

ocr ×1

pdf ×1

pdf-scraping ×1

pdfminer ×1

python ×1