PdfDocument class
A PDF document with page-level semantics on top of the COS layer.
Properties
- catalog → CosDictionary
-
no setter
- cos → CosDocument
-
The underlying COS-level document, for anything not surfaced here yet.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
info
→ Map<
String, String> -
Document information dictionary (/Title, /Author, ...) as text.
no setter
- pageCount → int
-
The number of reachable page leaves. Deliberately NOT the root
/Count: real-world files lie about it (and fuzzed ones make it a
reference to a stream), and an index below pageCount must never
make page throw. The walk caches in
_leafCache; /Count is still used as the subtree-skipping hint inside page.no setter -
pages
→ List<
PdfPage> -
Every reachable page in document order, resolved in one page-tree walk.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- version → String
-
no setter
Methods
-
applyIncrementalUpdate(
Uint8List newBytes) → Set< int> -
Feeds an append-only incremental revision into this open document in
place (see
CosDocument.applyIncrementalUpdate) and re-walks the page tree, so a render worker can reflect one page's edit without re-parsing the whole document.newBytesmust begin with this document's current bytes (cos.bytes). Returns the set of redefined COS object numbers. Throws when the update cannot be applied incrementally; the caller should re-open instead. -
invalidatePageCache(
) → void - Drops cached page-tree state. Editing code calls this after structural changes (reorder, removal, insertion) so lookups re-walk the tree.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openAppended(
Uint8List bytes, {String password = ''}) → PdfDocument -
Opens
bytes- this document's bytes with incremental updates appended (e.g. aPdfEditorsave over it), or the prefix an earlier revision ended at - with this document's already authenticated keys, so a freshly written revision of an encrypted file reopens without its password, and an undo does not re-run the password check. A revision whose /Encrypt differs authenticatespasswordinstead. SeeCosDocument.openAppended. -
page(
int index) → PdfPage -
Returns page
index(zero-based), with inheritable attributes (Resources, MediaBox, CropBox, Rotate) resolved along the tree path. -
pageIndexOf(
CosDictionary pageDict) → int - Zero-based index of a page dictionary, or -1 if it isn't a leaf of this document's page tree. Resolved objects are cached by reference, so identity comparison is sound. Used to resolve link destinations.
-
rollbackTo(
int length) → ({Set< int> changed, int steps})? -
Takes this open document back to an earlier revision it advanced past
with applyIncrementalUpdate (see
CosDocument.rollbackTo) and drops the page-tree caches, so a render worker can follow an undo without re-parsing the document or losing the objects the undone revisions did not touch.lengthis that revision's byte length;cos.bytesmust still hold it as their prefix. Returns the redefined COS object numbers and how many revisions were undone, or null - nothing changed - whenlengthis not a revision this document can roll back to; re-open instead. -
toString(
) → String -
A string representation of this object.
inherited
-
withIncrementalUpdate(
Uint8List newBytes) → PdfDocument - Folds an append-only revision into the COS layer (see applyIncrementalUpdate) and returns a fresh PdfDocument over it.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
open(
Uint8List bytes, {String password = '', List< int> ? populatedRanges}) → PdfDocument -
Opens a document. For encrypted files
passwordis tried first as the user and then as the owner password (the empty default is what most owner-locked business documents expect); a wrong password throwsCosPasswordException. -
openSource(
PdfByteSource source, {String password = '', PdfSourceLoadOptions options = const PdfSourceLoadOptions()}) → Future< PdfDocument> -
Opens a document from an asynchronous, random-access
source- a remote file over HTTP Range requests, a local file read on demand, or any other PdfByteSource. Only the bytes the parser needs (header, cross-reference chain, and the live objects) are fetched, falling back to a full download when the source cannot serve useful ranges or the file is malformed.