PdfDocument class
The main entry point for creating PDF documents.
Example:
final document = PdfDocument();
document.pages.add().graphics.drawString(
'Hello World!',
PdfStandardFont(PdfFontFamily.helvetica, 12),
brush: PdfSolidBrush(PdfColor(0, 0, 0)),
bounds: Rect.fromLTWH(0, 0, 200, 50),
);
final bytes = document.save();
document.dispose();
Constructors
- PdfDocument()
- Create a new empty PDF document.
- PdfDocument.fromBase64(String base64Data)
-
Create a PdfDocument from base64-encoded PDF data.
factory
- PdfDocument.fromBytes(Uint8List bytes)
-
Create a PdfDocument from raw PDF bytes.
factory
Properties
- bookmarks → PdfBookmarkCollection
-
final
- documentInfo → PdfDocumentInfo
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLoaded → bool
-
Whether this document was loaded from existing PDF data.
no setter
- pages → PdfPageCollection
-
final
- rawBytes → Uint8List?
-
Get the raw bytes of the original PDF (if loaded).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → void - Dispose resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
save(
) → List< int> - Save the document and return PDF bytes.
-
saveAsBase64(
) → String - Save the document and return as base64 string.
-
saveAsNew(
) → List< int> - Re-serialize the document from scratch (for new or modified documents). Note: For loaded documents, use save to preserve original formatting.
-
saveOriginalBytes(
) → List< int> ? - Save only the original bytes (if loaded from base64/bytes). Returns null if this is a newly created document.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited