PdfViewerController class
Controller for loading and managing PDF documents in the viewer.
Supports loading from multiple sources: PdfDocument, raw bytes, base64-encoded strings, or file paths.
Example:
// From a programmatically created document:
final doc = PdfDocument();
doc.pages.add().graphics.drawString(...);
final controller = PdfViewerController.fromDocument(doc);
// From base64:
final controller = PdfViewerController.fromBase64(base64String);
// From bytes:
final controller = PdfViewerController.fromBytes(pdfBytes);
Constructors
- PdfViewerController.fromBase64(String base64Data)
- Create a controller from a base64-encoded PDF string.
- PdfViewerController.fromBytes(Uint8List bytes)
- Create a controller from raw PDF bytes.
- PdfViewerController.fromDocument(PdfDocument document)
- Create a controller from a PdfDocument.
Properties
- currentPage ↔ int
-
Current page index (0-based).
getter/setter pair
- document → PdfDocument
-
The underlying PDF document.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- onPageChanged ↔ void Function(int pageIndex)?
-
Optional callback when the page changes.
getter/setter pair
- pageCount → int
-
Total number of pages.
no setter
- pdfBytes ↔ Uint8List
-
The raw PDF bytes for rendering.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → void - Dispose resources.
-
firstPage(
) → void - Go to the first page.
-
getPageHeight(
int index) → double - Get page height for a specific page index.
-
getPageWidth(
int index) → double - Get page width for a specific page index.
-
lastPage(
) → void - Go to the last page.
-
nextPage(
) → void - Go to the next page.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
previousPage(
) → void - Go to the previous page.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited