pdfq is a Rust command-line utility for searching text in PDF files, designed to work as a fast, parallel alternative to pdfgrep. It extracts text one page at a time using the pure-Rust pdf-extract library, applies regular expressions with Rust’s regex engine (or fancy-regex when Perl-compatible matching is requested), and uses Rayon to process pages and files across available CPU cores. Its CLI aims to preserve pdfgrep’s flags, output conventions, and exit codes, making it suitable as a drop-in replacement. Supported features include case-insensitive, fixed-string, and count-only searches; filename-only output; context pages; page ranges; recursive directory searches; colored output; and an optional cache of extracted text.
The program returns 0 when it finds a match, 1 when there are no matches, and 2 for errors, with quiet mode returning success as soon as a match is found. Output identifies the file and PDF page, and supports NUL-separated filenames. Some differences from pdfgrep matter for users comparing results: text layout can vary because extraction uses a different library; periods do not match newlines, and anchors apply to the whole page; recursive results are sorted; and accent folding is unsupported. The project includes unit and integration tests, plus an optional differential test suite that compares its output and exit status against an installed pdfgrep. It is released under the MIT license and can be built with Cargo.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.