PdfEditor class

Mutable PDF editor — parse once, mutate many times, save once.

Constructors

PdfEditor.internal(PdfBridge _, BridgeEditorHandle _handle, {PdfEncryptionAlgorithm? sourceEncryption, PdfPermissions? sourcePermissions, String? password, PdfDoc? sourceDoc})
Internal constructor — use Pdf.edit to create instances.

Properties

hashCode int
The hash code for this object.
no setterinherited
isModified PdfTask<bool>
Whether unsaved modifications exist.
no setter
pageCount PdfTask<int>
Current number of pages in the document.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
version PdfTask<String>
PDF version string of the document.
no setter

Methods

addImageStamp(int page, DataSource imageData, {required PdfRect rect, double opacity = 1.0}) PdfTask<void>
Adds a custom image stamp to the specified page.
addRedaction(int page, PdfRect region, {String? overlayText}) PdfTask<void>
Marks a region on page for redaction (applied with applyRedactions).
addStamp(int page, {required PdfStampType type, required PdfRect rect, double opacity = 1.0}) PdfTask<void>
Adds a predefined stamp annotation to the specified page.
addWatermark(int page, String text, {PdfWatermarkStyle style = const PdfWatermarkStyle(), PdfWatermarkPosition position = const PdfWatermarkPosition.center(), PdfWatermarkLayer layer = PdfWatermarkLayer.foreground}) PdfTask<void>
Adds a text watermark to the specified page.
applyRedactions() PdfTask<void>
Permanently applies all pending redaction marks, removing content.
convertToPdfA({int level = 1}) PdfTask<void>
Converts the document to PDF/A at the given conformance level.
cropMargins({double left = 0, double right = 0, double top = 0, double bottom = 0}) PdfTask<void>
Crops all pages by the specified margins (in points).
deletePage(int page) PdfTask<void>
Removes the given page (0-based index) from the document.
dispose() Future<void>
Releases editor resources and the underlying doc handle. Idempotent.
embedFile(String name, DataSource data) PdfTask<void>
Embeds data as an attached file with the given name.
eraseRegions(int page, List<PdfRect> regions) PdfTask<void>
Erases content within the specified regions on page.
flattenAllAnnotations() PdfTask<void>
Flattens all annotations (forms, comments, stamps) into static content.
flattenForms() PdfTask<void>
Flattens all interactive form fields into static content.
getAuthor() PdfTask<String>
Returns the document author metadata.
getCreationDate() PdfTask<String>
Returns the document creation date as a raw PDF date string (e.g. D:20240101120000Z).
getKeywords() PdfTask<String>
Returns the document keywords metadata.
getPageMediaBox(int page) PdfTask<PdfRect>
Returns the media box (bounding rectangle) of the given page.
getProducer() PdfTask<String>
Returns the document producer metadata (the software that produced the PDF).
getSubject() PdfTask<String>
Returns the document subject metadata.
getTitle() PdfTask<String>
Returns the document title metadata.
mergeFrom(DataSource otherPdf) PdfTask<void>
Appends all pages from otherPdf at the end of this document.
movePage({required int from, required int to}) PdfTask<void>
Moves the page at index from to index to.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
optimizeImages({int quality = 75, int minSize = 128}) PdfTask<int>
Recompresses images above minSize pixels at the given quality.
redactionCount(int page) PdfTask<int>
Returns the number of pending redaction marks on page.
resizeImage(int page, String imageName, {required double width, required double height}) PdfTask<void>
Resizes the named image on page to width x height points.
rotateAllPages({required int degrees}) PdfTask<void>
Rotates all pages by degrees (must be a multiple of 90).
rotatePage(int page, {required int degrees}) PdfTask<void>
Rotates a single page by degrees (must be a multiple of 90).
save(DataSink output, {PdfSaveOptions options = const PdfSaveOptions.fullRewrite()}) PdfTask<void>
Writes the modified document to output with the given save options.
scrubMetadata() PdfTask<void>
Removes all document metadata (title, author, timestamps, etc.).
selectPages(List<int> pages) PdfTask<void>
Keeps only the specified pages (by index), removing all others.
setAuthor(String value) PdfTask<void>
Sets the document author metadata.
setCreationDate(String value) PdfTask<void>
Sets the document creation date. Expects a raw PDF date string (e.g. D:20240101120000Z).
setFormFieldValue(String fieldName, String value) PdfTask<void>
Sets the value of the form field identified by fieldName.
setKeywords(String value) PdfTask<void>
Sets the document keywords metadata.
setProducer(String value) PdfTask<void>
Sets the document producer metadata.
setSubject(String value) PdfTask<void>
Sets the document subject metadata.
setTitle(String value) PdfTask<void>
Sets the document title metadata.
toString() String
A string representation of this object.
inherited
unembedStandardFonts() PdfTask<int>
Removes embedded copies of standard PDF fonts to reduce file size.

Operators

operator ==(Object other) bool
The equality operator.
inherited