Apr-20-2018, 07:54 PM
Also indentation always 4-space,never single
You open file 2 times in first code.
\
that way in filename Windows.You open file 2 times in first code.
from PyPDF2 import PdfFileReader, PdfFileWriter import os directory = os.listdir("E:/pdf/1") for file in directory: if file.endswith(".pdf"): pfile = "E:/pdf/1/" + file pdfFile = PdfFileReader(open(pfile, 'rb')) page = pdfFile.getPage(0) print(page.extractText())