Awesome-Python-Scripts/PDF2text/script.py
QuangPH d7b46ecaac
add script for convert pdf to text (#183)
Co-authored-by: pham.huu.quang <SUN-ASTERISK\pham.huu.quang@b121686-lt.sun-asterisk.com>
2020-10-09 17:09:01 +05:30

16 lines
321 B
Python

import os
import pdftotext
pdf_path = input("Enter the path of the pdf file : ")
assert os.path.exists(pdf_path), "this pdf file doesn't exist"
with open(pdf_path, 'rb') as f_r:
pdf_pages = pdftotext.PDF(f_r)
for i, page in enumerate(pdf_pages):
print('Page {}'.format(i))
print(page)
print('*'*100)