$ show weareprestatech/hotpdf
hotpdf is a Python library for fast and memory-efficient PDF text extraction and search. It wraps pdfminer.six to load PDF pages into memory using a sparse matrix representation, a trie for text search, and a span map for grouping characters. The library provides a HotPdf class with methods to find text (with options for case sensitivity and span extraction), extract text from bounding boxes, extract spans, and merge multiple PDF documents. The architecture separates concerns into processing (processor.py), memory mapping (memory_map.py), data structures (data/classes.py), and utilities (utils.py).
The LLM identified 2 files worth highlighting for reuse:
A memory-efficient 2D sparse matrix implementation that stores only non-empty cells. It automatically updates dimensions and provides efficient get/set operations. This component can be reused in any application requiring a sparse grid (e.g., games, simulations) without modification.
A collection of utility functions for processing text layout in PDFs, including finding adjacent characters, filtering coordinate groups, calculating element dimensions, checking bounding box intersection, and converting hot characters to text. These functions solve common problems in text extraction and are decoupled from PDF-specific parsing, making them reusable in other text processing contexts.