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.
- OcrInput
- An image to read text from.
- OcrLine
- A line of recognised text.
- OcrResult
- What a TextRecognizer read from an image.
- OutlineEntry
- One line of a document's outline (its table of contents): a PDF's bookmarks, a Word document's headings, a deck's slide titles, a Markdown file's headings.
- 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.
- PdfHighlight
- A coloured mark over a PdfTextRange, painted by PdfView under the selection. The package draws it; keeping highlights between sessions is the app's job (see PdfController.selectedRanges and PdfController.setHighlights).
- 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.
- PdfLink
- A link on a page: a web address, or a page in this document.
- PdfOutlineEntry
- A bookmark: one line of the PDF's table of contents.
- 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.
- PdfTextRange
- A stretch of one PDF page's text: characters start to end (exclusive) of the page's text as PDFium reads it. text is what those characters said when the range was made, so an app that saved the range can tell whether it still fits the document.
- PdfView
- PositionKeys
- Keys used in ReadingPosition maps, per reader.
- TextRecognizer
- Reads text from images (OCR).
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.
- PdfOcrStatus
- Where OCR is for a page.
- 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
- PdfPageOverlayBuilder = Widget? Function(BuildContext context, int page, Size pageSize)
- Shows the PDF a PdfController has opened, in its layout.
-
PdfPasswordProvider
= Future<
String?> Function() - Asked for a password when a PDF is encrypted; null gives up.
-
PdfSelectionMenuItems
= List<
ContextMenuButtonItem> Function(BuildContext context, PdfController controller) -
Extra items for the menu that opens over selected text, after Copy and
Select all: highlight, bookmark, look up.
controllerhas the selection (PdfController.selectedText). -
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.