forked from VincentGranville/Large-Language-Models
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf.py
More file actions
27 lines (19 loc) · 832 Bytes
/
Copy pathpdf.py
File metadata and controls
27 lines (19 loc) · 832 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
# https://www.geeksforgeeks.org/working-with-pdf-files-in-python/
# https://www.geeksforgeeks.org/how-to-extract-images-from-pdf-in-python/
# https://www.geeksforgeeks.org/how-to-extract-pdf-tables-in-python/
# https://stackoverflow.com/questions/2196621/how-to-extract-formatted-text-content-from-pdf
# https://www.freecodecamp.org/news/extract-data-from-pdf-files-with-python/
# importing required modules
import PyPDF2
# creating a pdf file object
pdfFileObj = open('abi-test.pdf', 'rb')
# creating a pdf reader object
pdfReader = PyPDF2.PdfReader(pdfFileObj)
# printing number of pages in pdf file
print(len(pdfReader.pages))
# creating a page object
pageObj = pdfReader.pages[0]
# extracting text from page
print(pageObj.extract_text())
# closing the pdf file object
pdfFileObj.close()