January 2019
Beginner
318 pages
8h 23m
English
To extract the pages of the pdf file, the PyPDF2 module has the extractText() method. Create a script called extract_text.py and write the following content in it:
import PyPDF2with open('test.pdf', 'rb') as pdf: read_pdf = PyPDF2.PdfFileReader(pdf) pdf_page = read_pdf.getPage(1) pdf_content = pdf_page.extractText() print(pdf_content)
Run the script and you will get the following output:
student@ubuntu:~/work$ python3 extract_text.py
Following is the output:
3Pythoncommands93.1Comments.........................................93.2Numbersandotherdatatypes..............................93.2.1Thetypefunction................................93.2.2Strings.......................................103.2.3Listsandtuples................................ ...
Read now
Unlock full access