talira

A set of Rust crates for parsing, interpreting and rendering PDF files.

open sourceApache-2.0 OR MITself-hostablefree

hayro is a family of pure-Rust crates for reading PDFs: hayro-syntax parses them read-only, hayro-interpret runs their content streams into an abstract device, hayro rasterizes pages to bitmaps on the CPU and hayro-svg converts pages to SVG. Image decoders for JPEG 2000, JBIG2 and CCITT, and font and CMap parsers, are separate crates that can be used on their own. Its author describes it as the most correct PDF renderer in Rust, checked by a visual regression suite of over 1,600 PDFs largely taken from the pdf.js and PDFBox test suites; it doesn't edit documents.

Problems it solves

  • render PDF pages to images in pure Rust without poppler
  • make PNG thumbnails of uploaded PDFs without shipping a C library or a GPL tool
  • convert PDF pages to SVG from a Rust program
  • parse a PDF quickly and read-only without building an editable document model
  • decode JPEG 2000 or JBIG2 images embedded in scanned PDFs in Rust
  • pdfium bindings make our Rust build and deployment painful across platforms
  • render untrusted PDFs with no unsafe code in the renderer
  • show previews of PDF pages in a WebAssembly app
  • walk the drawing operations on a PDF page to extract text positions or paths
  • rasterize PDFs on a server with no GPU

Features

  • read-only PDF parsing (hayro-syntax)
  • content stream interpreter with an abstract device (hayro-interpret)
  • CPU rasterization to bitmaps (hayro)
  • PDF to SVG (hayro-svg)
  • standalone JPEG 2000, JBIG2 and CCITT decoders
  • font and CMap parsers
  • embedded standard fonts and CMaps (default features)
  • 1,600+ PDF visual regression suite
  • unsafe code forbidden in the hayro crate
  • online demo viewer

Alternatives

The same job

These do what hayro does.

  1. pdfium-render A high-level idiomatic Rust wrapper around Pdfium, the C++ PDF library used by the Google Chromium project.
  2. MuPDF The ultimate library for managing PDF documents
  3. pdf-rs Rust library to read, manipulate and write PDF files.
  4. PDF.js PDF Reader in JavaScript
  5. PyMuPDF A high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.

Compare hayro with the top 3