Skip to content

PDF support via to_document / per-page extraction #62

Description

@adiberk

Context

We're evaluating anydoc as a replacement for our current Python-based extraction pipeline (PyMuPDF, openpyxl, python-docx, python-pptx). anydoc is dramatically faster and leaner — 378x faster on a 2.2MB XLSX, 40x less memory.

For PDFs, we're currently using pdf-inspector directly (extract_pages_markdown_bytes) to get per-page markdown. This works great, but it means we need two separate libraries for what feels like one job.

Request

Would it be possible to support PDFs in to_document() — or add a page-aware extraction mode to anydoc itself?

Currently:

  • to_document() raises UnsupportedError for PDFs ("PDF converts directly to Markdown; use to_markdown or to_markdown_bytes")
  • to_markdown_bytes() returns one blob with no page boundaries
  • pdf-inspector has extract_pages_markdown_bytes() which returns per-page markdown with page numbers, OCR flags, and table detection — exactly what we need

Ideally anydoc could either:

  1. Support to_document() for PDFs with page-level blocks, or
  2. Expose a to_markdown_pages() / to_markdown_bytes_pages() that wraps pdf-inspector's per-page extraction

This would let consumers use one library for all formats with consistent per-page output.

Workaround

Using pdf-inspector directly for PDFs and anydoc for everything else works fine — just adds a second dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Real, wanted, not urgentenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions