Skip to content

Instantly share code, notes, and snippets.

@alihanekiz
Created February 13, 2023 17:26
Show Gist options
  • Save alihanekiz/4667897dca6038245b4011299ec8ddd8 to your computer and use it in GitHub Desktop.
Save alihanekiz/4667897dca6038245b4011299ec8ddd8 to your computer and use it in GitHub Desktop.
PDF2TXT in Python
# importing required modules
from PyPDF2 import PdfReader
txtFilename = ''
pdfFilename = ''
text = ''
f = open(txtFilename, 'w')
reader = PdfReader(pdfFilename)
for page in reader.pages:
newText = page.extract_text()
text = text + newText
f.write(text)
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment