soev_indexing.backends
PDF backends that extract the text and the geometry of each page for PdfProcessor.
Backends
Each backend imports its PDF library at the first extraction, so this package imports without the extras.
PyMuPDFBackend
classPyMuPDFBackend()Stateless PDF backend using PyMuPDF and pymupdf4llm.
Imports pymupdf and pymupdf4llm lazily on first call to avoid import-time overhead.
It needs the extra [pdf]. PyMuPDF is not thread-safe, so one extraction at a time runs in a process,
across all instances. Run more processes for more throughput. The geometry holds one rectangle for each text
block of a page, and no image blocks.
methodextract(raw_bytes) -> PdfExtractionResultExtract text from PDF bytes using pymupdf4llm.
Opens the PDF from an in-memory byte stream, calls pymupdf4llm.to_markdown with page_chunks=True, and reads pymupdf4llm's already-1-based metadata page numbers.
paramraw_bytesbytesRaw PDF file bytes.
Returns
PdfExtractionResultExtraction result with per-page text (1-based page numbers).
Raises:
pymupdf.FileDataError: PyMuPDF cannot open the PDF, for example because the bytes are empty or are not a PDF. It is aRuntimeError.ImportError: The extra[pdf]is not installed.
LiteParseBackend
classLiteParseBackend()Stateless PDF backend using liteparse.
Imports liteparse lazily on first call, so the module imports without the
[liteparse] extra. Satisfies the PdfBackend protocol.
It needs the extra [liteparse]. It reads the native text of the PDF and does no OCR. PDFium is not
thread-safe, so one extraction at a time runs in a process, across all instances. A page text that does not end
with a line break gets a blank line at its end, so the pages of the markdown stay apart.
methodextract(raw_bytes) -> PdfExtractionResultExtract per-page markdown + geometry from PDF bytes.
paramraw_bytesbytesRaw PDF file bytes.
Returns
PdfExtractionResultExtraction result with 1-based page numbers, page
dimensions in points, and per-page (text, bbox, kind)
geometry from liteparse's text_items.
Raises:
liteparse.ParseError: If the PDF cannot be parsed.ImportError: The extra[liteparse]is not installed.