Nelsonkenneth / Online-PDF-to-Audio-converter-

A program that can read any PDF text file and convert it to an Audio file. In this Repository we have the main python program and sub programs like the function to read the PDF file and others
MIT License
1 stars 1 forks source link

PDF reader #1

Open Nelsonkenneth opened 1 year ago

Nelsonkenneth commented 1 year ago

Here a small function to read the pdf file and store it, so as to convert it later on.

Example:

PATH = " pdf path"

i = 1

pdf_files = [] docx_files = []

append document names into the lists by their extension type

for f in os.listdir(PATH): full_name = os.path.join(PATH, f) if os.path.isfile(full_name): name = os.path.basename(f) filename, ext = os.path.splitext(name) if ext == '.pdf': pdf_files.append(name) elif ext == ('.docx'): docx_files.append(name)

Nelsonkenneth commented 1 year ago

Now we need to sort the pdf files according to their types. I will start this by creating to lists one for pdf files and one for Docx files because these two types are the most used pdf file types: