pdf library

PDF documents, rendered by PDFium.

PdfView shows a document that a PdfController has opened: pages laid out continuously or side by side (PdfViewMode), pinch and double-tap zoom, text search and links. PdfPageThumbnail draws one page small.

PdfiumDocument is the engine underneath, for apps that render or extract text themselves.

Classes

DocumentController
What every format's controller does, so an app can build one toolbar, search bar and position display for all of them.
DocumentLocation
Where the reader is in a document: "page 3 of 12", "row 40 of 900".
DocumentSearchState
A search in a document: the query, how many times it occurs and which occurrence is current.
DocumentViewerStrings
The text the package's widgets show: messages, labels, tooltips and screen-reader descriptions. English by default.
DocumentViewerStringsScope
Gives the package's widgets below it strings instead of English.
DocumentViewerTheme
Colours the package's views use for search matches, as a ThemeExtension on the app's theme.
PdfController
Opens a PDF for PdfView: the document (asking passwordProvider for the password of an encrypted one), the page on screen, the layout (viewMode), zoom and search.
PdfiumDocument
An open PDF. All PDFium work happens in one shared background isolate; this object holds the document's id there and its page sizes.
A link on a page: a web address, or a page in this document.
PdfPageText
A page's text as PDFium reads it, with each character's box.
PdfPageThumbnail
A whole page as a small image (e.g. a thumbnail strip), rendered at low priority.
PdfRenderedImage
A rendered region of a page, as RGBA pixels.
PdfRenderTask
A cancellable render request. cancel drops it if it hasn't started, and result then fails with PdfCancelledException.
PdfSearchController
Text search over a PDF, page by page in the PDF worker; matches arrive as each page is searched.
PdfTextMatch
A search hit on one page: the boxes it covers, one per line.
PdfView
Shows the PDF a PdfController has opened, in its layout.
PositionKeys
Keys used in ReadingPosition maps, per reader.

Enums

DocumentLoadError
Why a document couldn't be opened.
DocumentStatus
Where a DocumentController is in its document's life.
DocumentUnit
What DocumentLocation.current and DocumentLocation.count count.
PdfOpenError
Why a PDF couldn't be opened.
PdfPriority
How urgently a request is served: what's on screen first.
PdfViewMode
How pages are laid out. A vertical single-page-snap mode isn't offered: horizontal already covers reading one page at a time.

Extensions

PdfMatchRects on PdfTextMatch
Rect helpers for page-space search hits.

Typedefs

PdfPasswordProvider = Future<String?> Function()
Asked for a password when a PDF is encrypted; null gives up.
ReadingPosition = Map<String, Object?>
A reader's saved place in a document, as plain JSON-safe values.

Exceptions / Errors

PdfCancelledException
A request was cancelled before it ran.
PdfEngineException
The worker went away (e.g. the native library failed to load).
PdfOpenException
Thrown when PDFium can't open a document; error says why.