feat(pdf): return positioned image files with Markdown - #83
Draft
qin-ctx wants to merge 3 commits into
Draft
Conversation
qin-ctx
marked this pull request as ready for review
August 12, 2026 09:55
qin-ctx
marked this pull request as draft
August 12, 2026 11:18
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
AnyDoc uses
pdf-inspectorto convert PDFs to Markdown. The current PDF API returns Markdown only, so an embedded image is either omitted or represented by a marker that cannot be matched to image data.OpenViking is integrating AnyDoc as its document parser. It needs one PDF conversion result containing:
Without this result, OpenViking would have to parse the PDF a second time and guess where each extracted image belongs.
Before
The existing API returns Markdown only:
It does not return image bytes or a filename that can be matched to a Markdown image target.
After
The new API returns Markdown, positioned PNG files, and PDF diagnostics together:
For a PDF containing text, an image, and more text, the result looks like this:
The returned image uses the exact same filename:
The binding rule is simple: the Markdown target equals
image.filename. A caller savesimage.dataunder that filename. No generated asset ID, coordinate matching, or second PDF pass is required.Each image also contains its source bounding box, PNG dimensions, PNG bytes, and renderer warning codes. Repeated placements are returned as separate files because their position and rendered appearance can differ.
The result also includes:
page_count;pages_needing_ocr;ocr_reasons_by_page;pages_with_tables;pages_with_columns;is_complex_layout;has_encoding_issues.Compatibility
The existing
to_markdownandto_markdown_bytesAPIs do not change. The new behavior is available only throughpdf_to_markdown_with_images.AnyDoc still does not perform OCR. Scanned and image-only PDFs continue to return the existing unsupported error.
API surface
pdf_to_markdown_with_images, behind the optionalpdf-imagesfeaturepdf_to_markdown_with_imagespdfToMarkdownWithImagesDependency status
This Draft PR depends on pdf-inspector#367, which is stacked on pdf-inspector#280. The Cargo dependency is pinned to the exact Draft commit for reproducible review. It must use a released upstream version before merge.
Validation
cargo check --workspace --all-featurescargo clippy --workspace --all-targets --all-features -- -D warningspdf-imagesfeatureThe generated PDF produced Markdown containing
and a real PNG namedp1_i1.png. The PNG was 557×334 pixels and 1,738 bytes. One existing test case was updated; no test file or test function was added.OpenViking needs this complete result to integrate AnyDoc without maintaining a second PDF image parser. Thank you for considering this integration requirement.