PDF

The PDF service reads the text and draws the pages of PDF files with PDFKit. Access it via app.pdf. Pages are numbered from 0; a locked PDF needs its password.

print(app.pdf.text("~/Documents/invoice.pdf"))

page = app.pdf.render("~/Documents/scan.pdf", page=0, width=1200)
print(app.vision.text(page))

Methods

Method Returns Description
page_count(path, password=None) int How many pages
text(path, pages=None, password=None) str The text, pages separated by a form feed (\f). pages is a list of page numbers; every page by default
render(path, page=0, width=None, password=None) bytes A page as PNG, width points wide with the page's proportions, drawn at the screen scale

A scanned PDF has no text layer, so text gives empty pages: draw them with render and read them with app.vision.text.