pdf_manipulator library

Cross-platform PDF manipulation.

Powered by pdf_oxide (Rust, MIT/Apache-2.0). Zero main-thread blocking on every platform including web. No dart:io. No dart:ffi.

import 'package:pdf_manipulator/pdf_manipulator.dart';

final pdf = Pdf();

// Open once, query many times, dispose when done
final doc = await pdf.open(source);
print('${doc.pageCount} pages');
final text = await doc.extract(pages: PdfPages.all());
final hits = await doc.search(query: 'hello', pages: PdfPages.all());
await doc.dispose();

// One-shot operations
await pdf.merge([sourceA, sourceB], outputSink);
await pdf.sign(source, outputSink, credentials: creds);

await pdf.dispose();

Classes

DataSink
Sequential byte destination — any output target.
DataSource
Random-access byte source — any file, any backing store.
MemorySink
A DataSink that collects written chunks into an in-memory buffer.
MemorySource
A DataSource backed by an in-memory byte buffer.
Pdf
Entry point for all PDF operations — open, edit, build, and standalone ops.
PdfAttachment
One file embedded in a document's /Names /EmbeddedFiles tree.
PdfBookmarkSplit
A bookmark-based split plan entry.
PdfBuilder
Creates PDFs from scratch — add pages with content, then save.
PdfCertificateInfo
X.509 certificate information.
PdfCheckedValue
Whether a checkbox or radio button is on.
PdfChoiceValue
The selected option of a single-select choice field.
PdfColor
RGB color for watermarks and annotations.
PdfConfig
Configuration for a PDF engine instance.
PdfDoc
A parsed PDF document — live handle to the Rust engine.
PdfDocumentClassification
Document classification result.
PdfEditor
Mutable PDF editor — parse once, mutate many times, save once.
PdfEncryption
Encryption intent on save — sealed, compiler-enforced.
PdfEncryptionConfig
Apply new encryption with explicit parameters.
PdfEncryptionKeep
Keep existing encryption unchanged.
PdfEncryptionRemove
Remove all encryption.
PdfFormField
An AcroForm field as read from a document by PdfDoc.formFields.
PdfFormFieldValue
A field's value, typed by the field kind: PdfTextValue for text fields, PdfCheckedValue for a checkbox or radio button, PdfChoiceValue for a single-select choice field, PdfMultiChoiceValue for a multi-select list box, PdfNoValue when the field has no value.
PdfImage
An image extracted from a PDF page.
PdfImageOutcome
One image XObject's outcome from PdfEditor.reduceImages.
PdfImagePolicy
How far PdfEditor.reduceImages may go.
PdfImageReport
The result of PdfEditor.reduceImages: one row per image XObject drawn on the document's pages, in ascending object number.
PdfMatrix
A PDF affine transform [a b c d e f] (ISO 32000-1 §8.3.4).
PdfMultiChoiceValue
The selected options of a multi-select list box.
PdfNoValue
A field with no value set.
PdfPageBuilder
Page content builder — add text, images, forms, watermarks.
PdfPageClassification
Page classification result.
PdfPageImage
An image XObject as placed on a page.
PdfPageInfo
Per-page metadata.
PdfPages
Which pages an operation targets.
PdfPagesAll
Every page.
PdfPagesList
Specific pages.
PdfPagesRange
Contiguous range [start, end).
PdfPagesSingle
One page.
PdfPemCredentials
PEM-encoded signing credentials.
PdfPermissions
Permission flags for encrypted PDFs.
PdfPkcs12Credentials
PKCS#12 signing credentials.
PdfRect
A rectangle in PDF coordinate space (points, 1pt = 1/72 inch).
PdfRedactionReport
What a destructive redaction pass actually removed, so the caller can assert the redaction did real work instead of trusting a silent no-op.
PdfRenderSize
Output size constraint for rendering.
PdfSanitizeOptions
What PdfEditor.sanitize strips from a document. Defaults are what "sanitizer" means: strip metadata and scripts, keep attachments unless asked.
PdfSaveFullRewrite
Full-rewrite save with compression, GC, and encryption control.
PdfSaveIncremental
Incremental save — append-only, preserves signatures.
PdfSaveOptions
Save strategy — sealed so invalid combos are unrepresentable.
PdfSignatureInfo
Information about a digital signature in a PDF.
PdfSigningCredentials
Signing credentials — PKCS#12 bundle or separate PEM cert + key.
PdfTask<T>
A running engine operation: awaitable like a Future, cancellable with cancel.
PdfTextValue
The text content of a text or single-select choice field.
PdfValidationResult
Validation result.
PdfWatermarkCenter
Centered watermark position.
PdfWatermarkCorner
Corner-anchored watermark position.
PdfWatermarkExact
Exact-coordinate watermark position.
PdfWatermarkPosition
Where to place the watermark on the page.
PdfWatermarkStyle
Watermark text style.
PdfWatermarkTiled
Tiled watermark position.
PdfXfaInfo
What a document's XFA packet declares. PdfDoc.xfa is null when the document has no XFA at all, so this type never describes absence.
RenderedPage
A rendered page bitmap.
SearchResult
A text search result with position on the page.

Enums

PdfAttachmentRelationship
How an embedded file relates to the document that carries it (ISO 32000-2 associated files).
PdfChromaSubsampling
How the colour channels of a written JPEG are subsampled.
PdfCorner
Which corner to anchor a watermark.
PdfDocumentFormat
Office document format for conversion.
PdfEncryptionAlgorithm
PDF encryption algorithm.
PdfExtractionFormat
Text/content extraction format.
PdfFallbackFontKind
Which fallback font a Pdf.registerFallbackFont call supplies.
PdfFormDataFormat
Format for PdfDoc.exportFormData.
PdfFormFieldFlag
A form field flag bit (/Ff), positioned per ISO 32000-1:2008 Table 221 (common), 226 (button), 228 (choice) and 230 (text). Pass a set of these to PdfEditor.setFormFieldFlags.
PdfFormFieldType
The kind of an AcroForm field, refined from the raw /FT and /Ff bits so a caller never reads a flag directly.
PdfImageAction
What PdfEditor.reduceImages did to one image.
PdfImageColor
What an image's decoded samples mean.
PdfImageEncoding
How an image's samples are stored.
PdfImageKeepReason
Why an image was kept as stored.
PdfIoMode
I/O mode — how the engine reads source bytes and writes output.
PdfStampType
Standard stamp annotation type.
PdfTextAlignment
Text alignment of a text field's content (/Q).
PdfWatermarkLayer
Whether the watermark renders above or below page content.

Extensions

PdfStandalone on Pdf
One-shot operations — source in, sink out, no persistent handle.
PdfSugar on Pdf
Convenience wrappers — common multi-step PDF operations in one call.

Functions

readAllBytes(DataSource source) → Future<Uint8List>
Read the entire DataSource into bytes. Used internally by the bridge when the FFI layer needs the full data (secondary inputs).

Exceptions / Errors

PdfCancelled
The operation was cancelled — its Pdf instance was disposed, or the task itself was cancelled. Carried on the wire as response status 2, never matched by message text.
PdfCorrupted
The PDF data is structurally corrupt or unparseable.
PdfCryptoError
An encryption or decryption error.
PdfEngineError
The PDF engine encountered an internal error.
PdfError
Typed error hierarchy for PDF operations.
PdfExtractionFailed
Text or content extraction failed.
PdfInvalidArgument
An argument passed to a PDF operation was invalid.
PdfIoError
A file-system or network I/O error during a PDF operation.
PdfPageRangeError
A page index was outside the valid range.
PdfPasswordRequired
The PDF is password-protected and no password was supplied.
PdfSearchError
A text search operation failed.
PdfUnsupported
The requested operation is not supported by this engine.
PdfWrongPassword
The supplied password was incorrect.