Skip to main content

Crate pdfluent

Crate pdfluent 

Source
Expand description

§PDFluent — Pure-Rust PDF SDK

pdfluent is the public API for the PDFluent SDK. It provides a single, coherent entry point for PDF manipulation: loading, editing, rendering, merging, signing, encryption, redaction, PDF/A compliance, and more.

§Quick start

use pdfluent::prelude::*;

fn main() -> Result<()> {
    let mut doc = PdfDocument::open("invoice.pdf")?;
    doc.metadata_mut()
        .set_title("Processed Invoice")
        .commit()?;
    {
        let mut form = doc.form_mut();
        form.set_text("invoice_number", "INV-2026-0042")?
            .set_checkbox("paid", true)?;
    }
    doc.compress(CompressOptions::strict())?;
    doc.save("invoice-processed.pdf")?;
    Ok(())
}

§Licensing

There is no licence key, no tier and no activation call. PDFluent is published under the AGPLv3 with a commercial licence as the alternative, and a commercial licensee’s rights come from a signed order form rather than from a check in the binary. Nothing here reads a key, refuses a capability or marks output. See docs/licensing.md.

§Design foundation

The public API is frozen per RFC 0001 (see docs/rfc/0001-sdk-core-api.md). Breaking changes require a new RFC.

Re-exports§

pub use crate::compliance::PdfAProfile;
pub use crate::compliance::PdfAValidationReport;
pub use crate::compliance::Violation;
pub use crate::decoration::PageDecoration;
pub use crate::diagnostics::Diagnostic;
pub use crate::diagnostics::DiagnosticCategory;
pub use crate::diagnostics::LeniencyReport;
pub use crate::diagnostics::Severity;
pub use crate::document::OpenOptions;
pub use crate::document::Page;
pub use crate::document::Pages;
pub use crate::document::PdfDocument;
pub use crate::document::PdfVersion;
pub use crate::document::SaveOptions;
pub use crate::document::TextBlock;
pub use crate::encrypt::EncryptOptions;
pub use crate::encrypt::EncryptionAlgorithm;
pub use crate::encrypt::Permissions;
pub use crate::error::Error;
pub use crate::error::ResourceLimitKind;
pub use crate::error::Result;
pub use crate::form::FieldType;
pub use crate::form::FormField;
pub use crate::form::PdfFormMut;
pub use crate::images::DecodedImage;
pub use crate::images::ExtractedImage;
pub use crate::images::ImageColorSpace;
pub use crate::images::ImageId;
pub use crate::images::ImageInfo;
pub use crate::merger::BookmarkMergeStrategy;
pub use crate::merger::MergeOptions;
pub use crate::merger::PdfMerger;
pub use crate::metadata::Metadata;
pub use crate::metadata::MetadataMut;
pub use crate::parity::CompressOptions;
pub use crate::parity::CompressReport;
pub use crate::parity::FontSubsetReport;
pub use crate::parity::ImageFormat;
pub use crate::parity::ImageInsert;
pub use crate::parity::ImageInsertReport;
pub use crate::parity::InsertImageFormat;
pub use crate::parity::RenderPageOptions;
pub use crate::parity::ToImagesOptions;
pub use crate::parity::ToImagesReport;
pub use crate::redact::RedactOptions;
pub use crate::signer::PadesProfile;
pub use crate::signer::PdfSigner;
pub use crate::signer::Pkcs12Signer;
pub use crate::signer::SignOptions;
pub use crate::signer::SignatureInfo;
pub use crate::signer::SignatureStatus;
pub use crate::signer::SignatureValidation;
pub use crate::signer::SignatureValidationReport;
pub use crate::watermark::Layer;
pub use crate::watermark::Position;
pub use crate::watermark::Rotation;
pub use crate::watermark::WatermarkOptions;
pub use crate::xfa::XfaField;
pub use crate::xfa::XfaFieldOption;
pub use crate::xfa::XfaFieldType;
pub use crate::xfa::XfaFieldValue;
pub use crate::xfa::XfaFormModel;
pub use crate::xfa::XfaRect;
pub use crate::xfa::XfaSetOutcome;
pub use crate::xfa::XfaWidget;

Modules§

annotation
Annotation types.
async_ioasync-tokio
Async I/O wrappers built on Tokio.
compat
A second, compatible spelling of the document API, built on the facade.
compliance
PDF/A compliance types.
decoration
Unified page-decoration surface (Epic 3 #1225).
diagnostics
Public diagnostics model.
document
PdfDocument and lifecycle types.
encrypt
Encryption, decryption, and permissions.
error
Error types for pdfluent.
form
Form field reading and mutation.
images
Embedded-image extraction on the plain facade.
merger
PdfMerger — factory builder for merging multiple PDF documents.
metadata
Document metadata (Info dict + XMP).
model
The model tiers’ shared surface, re-exported from pdf-engine: the model specs, the failure types and the install paths (#641).
ocr
Optical character recognition.
parity
Options and reports for Epic 3 #1224 parity methods.
pdfa
PDF/A profiles and validation reports — an alias for compliance.
prelude
Convenient re-exports for common pdfluent usage.
redact
Redaction options.
signer
Digital signature types.
structure
Document-structure read APIs: outlines, annotations, attachments.
taggedpdfa
Reading the logical structure tree of a tagged PDF (ISO 32000-1 §14.7).
text_edit
Async I/O wrappers via Tokio’s blocking pool. Layout-aware text replacement engine (find & replace by match id). Layout-aware text editing: find → stage → commit (Phase 1B engine).
unicode_fontfont-subset
Embedding a caller-supplied Unicode font, so a replacement can contain scripts the document itself never had. See text_edit::FontFallback::EmbedUnicode. Embedding a caller-supplied Unicode font, so a replacement can contain characters the document’s own fonts have no glyph for. Embedding a caller-supplied Unicode font as a Type0 composite font, so a replacement can contain characters the original font has no glyph for.
watermark
Watermarking options.
xfa
XFA form field model — public DTOs for the Phase-1 XFA fill API.

Structs§

Block
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
DoclingPage
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
ExtractOptions
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
MarkdownOptions
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
ProcessingLimits
Re-export of pdf_engine::ProcessingLimits for use with OpenOptions::with_processing_limits. Resource limits for a single PDF processing operation.
TatrOptions
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
Word
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).

Enums§

BlockKind
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
OcrMode
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
OptionsError
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
PageSeparators
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
Quality
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
RasterQuality
Rasterization precision/speed trade-off for render paths, re-exported from the engine (one definition, not a facade copy, so callers holding a value from either crate hold the same type). Rasterization precision / speed trade-off for the vello_cpu pipeline.

Functions§

api_version
The SDK version at compile time. Bindings check this at runtime to ensure compatibility with the loaded pdfluent dynamic library.
join_page_texts
Re-export of pdf_engine::join_page_texts: the form-feed convention every PDF text reader emits, for callers that hold the pages from PdfDocument::extract_text_pages and want the flat form of them. Join per-page text the way pdftotext and mutool have for twenty years: a form feed (U+000C) after every page, preceded by a blank line so the last paragraph of a page is not glued to the separator.
to_docling_json
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
to_json
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
to_json_with_words
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
to_markdown
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
to_markdown_with_code
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
to_markdown_with_options
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).
to_words_json_lines
The block model and both serialisations of it, re-exported from pdf-engine: what PdfDocument::extract_blocks hands back, which pages it hands back, and the two ways to write them out (#573).