talira

pdfium-render

A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.

open sourceMIT OR Apache-2.0self-hostablefree

pdfium-render gives Rust a high-level, idiomatic API over Pdfium, the C++ PDF engine in Google Chrome. Through it a Rust program can render pages or parts of pages to bitmaps (as image crate images), extract text and images, fill and inspect form fields, inspect signatures, attachments, annotations and links, concatenate documents, and create pages with text, path and image objects. It binds to a Pdfium library at runtime (or links one statically), so the same code can compile to WebAssembly and run in a browser next to a WASM build of Pdfium. Pdfium itself isn't included: you download a prebuilt binary or build it.

Problems it solves

  • turn each page of a PDF into a JPEG or PNG from Rust
  • make thumbnails of uploaded PDFs in a Rust web service with Chrome's PDF engine
  • fill in PDF form fields from Rust and save the result
  • extract text with positions from PDF pages in Rust
  • render PDFs in the browser from a Rust WebAssembly app
  • merge PDF documents and add watermarks from Rust
  • read digital signatures, attachments and annotations from a PDF in Rust
  • add text, shapes and images to PDF pages using Pdfium from Rust
  • use Pdfium from Rust without writing unsafe FFI calls myself
  • render only a region of a large PDF page, or tile it, at high resolution

Features

  • render pages, or portions of pages, to bitmaps and image crate images
  • text and image extraction
  • form field introspection and filling
  • signature, attachment, annotation and link introspection
  • document concatenation and watermarking
  • create documents, pages, and text, path and bitmap page objects
  • custom fonts and custom text shaping inside a text object
  • binds to Pdfium at runtime (dynamic) or links it statically
  • compiles to WebAssembly alongside a WASM build of Pdfium
  • thread-safe access through a mutex (default feature)
View 1 more
  • crate features pin a specific Pdfium API version

Limitations

  • Doesn't include or build Pdfium: you supply a prebuilt Pdfium library to bind at runtime or link statically1
  • Doesn't speed anything up with threads: every call into Pdfium is serialized behind a mutex, so use separate processes for parallel work1

Capabilities

Has official SDKsplan not known

Alternatives

The same job

These do what pdfium-render does.

  1. hayro A set of Rust crates for parsing, interpreting and rendering PDF files.
  2. lopdf A Rust library for PDF document manipulation.
  3. pdf-rs Rust library to read, manipulate and write PDF files.
  4. PDF.js PDF Reader in JavaScript
  5. pypdfium2 Python bindings to PDFium, reasonably cross-platform
  6. MuPDF The ultimate library for managing PDF documents

Compare pdfium-render with the top 3