First steps¶
In this page you will read your first PDF. It takes about a minute.
Get a PDF¶
Download the sample report and save it as
report.pdf. It has three short pages, and every example in this documentation
uses it, so your output will match what you see here.
Write the code¶
Create a file called main.py in the same folder:
main.py
import ozaru
text = ozaru.extract_text("report.pdf")
pages = ozaru.page_count("report.pdf")
print(f"Pages: {pages}")
print(f"Title: {text.splitlines()[0]}")
Run it¶
You should see:
What just happened¶
ozaru.extract_textopenedreport.pdfand returned all of its text as astr.ozaru.page_countreturned the number of pages as anint.- From there it's regular Python:
splitlines()cut the text into lines, and[0]picked the first one.
Info
ozaru returns plain Python values. You don't have to open or close anything, because ozaru takes care of the file for you.
Next: learn more about extracting text.