Python: Read PDF: Difference between revisions
From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs) No edit summary |
Onnowpurbo (talk | contribs) No edit summary |
||
| Line 2: | Line 2: | ||
#install pyDF2 | #install pyDF2 | ||
pip install PyPDF2 | pip install PyPDF2 | ||
# importing all the required modules | # importing all the required modules | ||
import PyPDF2 | import PyPDF2 | ||
# creating an object | # creating an object | ||
file = open('example.pdf', 'rb') | file = open('example.pdf', 'rb') | ||
# creating a pdf reader object | # creating a pdf reader object | ||
fileReader = PyPDF2.PdfFileReader(file) | fileReader = PyPDF2.PdfFileReader(file) | ||
# print the number of pages in pdf file | # print the number of pages in pdf file | ||
print(fileReader.numPages) | print(fileReader.numPages) | ||
Revision as of 09:03, 28 October 2018
#install pyDF2 pip install PyPDF2
# importing all the required modules import PyPDF2
# creating an object
file = open('example.pdf', 'rb')
# creating a pdf reader object fileReader = PyPDF2.PdfFileReader(file)
# print the number of pages in pdf file print(fileReader.numPages)