Extract text from pdf converted from webpage using Pypdf2

前端 未结 1 1144
清歌不尽
清歌不尽 2021-01-28 13:47

I used chrome to convert a webpage into Pdf using save as pdf option. Now the problem is that when I extract the data from it using PyPDF2, it shows Null whereas it works on oth

相关标签:
1条回答
  • 2021-01-28 14:30

    PyPDF2 is highly unreliable for extracting text from pdf . as pointed out here too. it says :

    While PyPDF2 has .extractText(), which can be used on its page objects (not shown in this example), it does not work very well. Some PDFs will return text and some will return an empty string. When you want to extract text from a PDF, you should check out the PDFMiner project instead. PDFMiner is much more robust and was specifically designed for extracting text from PDFs.

    1. You could instead install and use pdfminer using

      pip install pdfminer

    2. or you can use another open source utility named pdftotext by xpdfreader. instructions to use the utility is given on the page.

    you can download the command line tools from here and could use the pdftotext.exe utility using subprocess .detailed explanation for using subprocess is given here

    0 讨论(0)
提交回复
热议问题