"converting a pdf file to a text file in python" Code Answer


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.

By Spiros Dellaportas on April 3 2022

Answers related to “converting a pdf file to a text file in python”

Only authorized users can answer the Search term. Please sign in first, or register a free account.