gitmyhub

pdq

Rust ★ 26 updated 7d ago

PDF split, merge, page-count, and render — pretty damn quick. Pure Rust, no C deps, no external tools.

pdq is a fast, dependency-free Rust tool and library for splitting, merging, counting, rendering, and extracting text from PDF files.

Rustsetup: easycomplexity 2/5

pdq is a command line tool and library for working with PDF files: splitting them apart, merging them together, counting pages, rendering pages to images, and pulling out text. It is written entirely in Rust with no dependence on external programs or C libraries, so it ships as a single self contained binary with nothing extra to install.

The project is built for speed on large or difficult files. According to the README, it can split a 200 megabyte, over 12,000 page PDF into one file per page in about a second, and it handles PDFs that trip up other established tools, including ones that hit timeouts on certain court documents. Encrypted PDFs using RC4 or AES are decrypted automatically when opened, and files with broken or missing internal indexes are repaired on the fly using the same recovery approach mainstream PDF readers use.

Command line usage covers common jobs: counting a file's pages, splitting a document into individual page files or fixed size chunks, extracting specific page ranges into new files, merging multiple PDFs into one, reading each page's dimensions and rotation without rendering anything, rasterizing pages to PNG images at a chosen resolution, and extracting positioned text runs as structured data. Page ranges can be written in flexible ways, such as picking pages from the end of the document or listing them out of order.

Installation is done through Rust's package manager, either by installing the published crate directly or building from a cloned copy of the source. Everything the command line tool does is also available as a library for use inside other Rust programs, with some extra options only available that way, such as choosing specific pages per input file when merging.

Where it fits