-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_pypdf2.py
More file actions
29 lines (24 loc) · 822 Bytes
/
_pypdf2.py
File metadata and controls
29 lines (24 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#این کد یک سری اطلاعات در مورد PDF انتخابی ما به ما می دهد
from PyPDF2 import PdfFileReader as PDFReader
from pprint import pprint
def get_info(pdf):
info = pdf.getDocumentInfo()
return {
'author': info.author,
'creator': info.creator,
'producer': info.producer,
'subject': info.subject,
'title': info.title,
'pages': pdf.getNumPages(),
'encrypted': pdf.getIsEncrypted()
}
def get_text(pdf):
# return list(map(lambda page: page.extractText(), pdf.pages))
for idx in pdf.getNumPages():
page = pdf.getPage(idx)
yield page.extractText()
if __name__ == '__main__':
path = input('Enter the PDF path: ')
pdf = PDFReader(path)
information = get_info(pdf)
pprint(information)