问题
I've been on it for several days + researching the internet on how to get specific information from a pdf file.
Eventually I was able to fetch all information using Python from a text file(which I created by going to the PDF file -----> File ------> Save as Text).
The question is how do I get Python to accomplish those tasks(Going to the PDF file(opening it - is quite easy open("file path"), clicking on File in the menu, and then saving the file as a text file in the same directory).
Just to be clear, I do not require the pdfminer or pypdf libraries as I have already extracted the information with the same file(after converting it manually to txt)
回答1:
You could use pdftotext.exe that you can download from http://www.foolabs.com/xpdf/download.html and then execute it on your pdf files via Python:
import os
import glob
import subprocess
#remember to put your pdftotxt.exe to the folder with your pdf files
for filename in glob.glob(os.getcwd() + '\\*.pdf'):
subprocess.call([os.getcwd() + '\\pdftotext', filename, filename[0:-4]+".txt"])
At least it worked for one of my projects.
来源:https://stackoverflow.com/questions/38496026/converting-a-pdf-file-to-a-text-file-in-python