PdfDocument class
Core PDF document model used to create and serialize PDF files.
Create a PdfDocument, add pages and objects, then call save to generate the final bytes.
Constructors
- PdfDocument({PdfPageMode pageMode = PdfPageMode.none, DeflateCallback? deflate, bool compress = true, bool verbose = false, PdfVersion version = PdfVersion.pdf_1_5})
- Creates a new PDF document.
- PdfDocument.load(PdfDocumentParserBase? prev, {DeflateCallback? deflate, bool compress = true, bool verbose = false})
- Loads a PDF using an existing parser.
- PdfDocument.parseFromBytes(Uint8List pdfBytes, {bool enableCache = true, int cacheBlockSize = 256 * 1024, int cacheMaxBlocks = 32, bool allowRepair = false})
-
Parses a PDF from in-memory bytes.
factory
- PdfDocument.parseFromReader(PdfRandomAccessReader reader, {bool enableCache = true, int cacheBlockSize = 256 * 1024, int cacheMaxBlocks = 32, bool allowRepair = false})
-
Parses a PDF from a random access reader.
factory
Properties
- catalog ↔ PdfCatalog
-
The document catalog object.
latefinal
- compress → bool
-
Whether compression is enabled (deprecated).
no setter
-
defaultOutlineBorder
↔ PdfObject<
PdfDataType> ? -
Default border for annotations, used during serialization.
getter/setter pair
- deflate → DeflateCallback?
-
Stream compression callback (deprecated).
no setter
- documentID → Uint8List
-
Generates or returns the document ID.
no setter
- dss ↔ PdfDssData?
-
DSS data (LTV).
getter/setter pair
- encryption ↔ PdfEncryption?
-
Encryption configuration for the document.
getter/setter pair
-
fonts
→ Set<
PdfFont> -
Fonts registered in this document.
final
- form → PdfAcroForm
-
AcroForm manager for general form fields.
no setter
- graphicStates → PdfGraphicStates
-
Graphic states for opacity and transfer modes.
no setter
- hasGraphicStates → bool
-
Whether this document has any graphic states.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- info ↔ PdfInfo?
-
The /Info dictionary (deprecated).
getter/setter pair
-
objects
→ Set<
PdfObject< PdfDataType> > -
All indirect objects that belong to this document.
final
- objser → int
-
Current object serial number.
no setter
- outline → PdfOutline
-
The document outline root.
no setter
- pageLabels → PdfPageLabels
-
Page label tree root.
no setter
- pdfNames → PdfNames
-
Name tree dictionary.
no setter
- pdfPageList → PdfPageList
-
Page tree root.
no setter
- prev → PdfDocumentParserBase?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings ↔ PdfSettings
-
PDF generation settings.
latefinal
- sign ↔ PdfSignature?
-
Document-level signature object.
getter/setter pair
- signatures → PdfSignatureFieldEditor
-
Signature field manager (AcroForm).
no setter
- verbose → bool
-
Whether verbose output is enabled (deprecated).
no setter
- version → PdfVersion
-
PDF version to generate.
no setter
- versionString → String
-
PDF specification version string.
final
Methods
-
addSignatureField(
{required int pageNumber, required PdfRect bounds, required String fieldName, void drawAppearance(PdfGraphics graphics, PdfRect bounds)?}) → PdfDocument - Adds a signature field at the given bounds.
-
addSignatureFieldTopLeft(
{required int pageNumber, required double left, required double top, required double width, required double height, required String fieldName, void drawAppearance(PdfGraphics graphics, PdfRect bounds)?}) → PdfDocument - Adds a signature field using top-left coordinates.
-
addUriAnnotation(
{required int pageNumber, required PdfRect bounds, required String uri}) → PdfDocument - Adds a URI annotation to the given page.
-
addUriAnnotationTopLeft(
{required int pageNumber, required double left, required double top, required double width, required double height, required String uri}) → PdfDocument - Adds a URI annotation using top-left coordinates.
-
ensureDss(
) → void - Initializes DSS data if needed.
-
genSerial(
) → int - Allocates a new indirect object serial number.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
output(
PdfStream os, {bool enableEventLoopBalancing = false}) → Future< void> - Writes the document to an output stream.
-
page(
int page) → PdfPage? - Returns a specific page by index.
-
removePageAt(
int index) → void - Removes a page by index (safe incremental edit).
-
save(
{bool enableEventLoopBalancing = false, bool useIsolate = true}) → Future< Uint8List> - Generates the PDF document as a memory buffer.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateInfo(
{String? title, String? author, String? creator, String? subject, String? keywords, String? producer}) → void - Updates /Info metadata fields.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited