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.
PdfBookmarkSplit
A bookmark-based split plan entry.
PdfBuilder
Creates PDFs from scratch — add pages with content, then save.
PdfCertificateInfo
X.509 certificate information.
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.
PdfImage
An image extracted from a PDF page.
PdfPageBuilder
Page content builder — add text, images, forms, watermarks.
PdfPageClassification
Page classification result.
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).
PdfRenderSize
Output size constraint for rendering.
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.
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.
RenderedPage
A rendered page bitmap.
SearchResult
A text search result with position on the page.

Enums

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.
PdfIoMode
I/O mode — how the engine reads source bytes and writes output.
PdfStampType
Standard stamp annotation type.
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.