Skip to content

fix(pdf): use extracted markdown when ImageBased pages yield text - #234

Open
DrSkyle wants to merge 2 commits into
firecrawl:mainfrom
DrSkyle:fix/pdf-image-based-caption-230
Open

DrSkyle wants to merge 2 commits into
firecrawl:mainfrom
DrSkyle:fix/pdf-image-based-caption-230

Conversation

@DrSkyle

@DrSkyle DrSkyle commented Nov 21, 2026 •

Copy link
Copy Markdown

Summary

An image-heavy PDF page with a short text caption can be classified as ImageBased. The fallback extraction finds the caption, but to_markdown discards it and returns an unsupported error.

When the initial Markdown is missing or blank and no flagged pages still need OCR, to_markdown now uses the extracted text. If only some pages were flagged, it extracts all pages so text from unflagged pages is preserved. Image-only pages still return NeedsOcr.

Fixes #230.

Test Plan

  • Added regression tests for an image-only page and an image with a short caption.
  • cargo +stable test --lib: 288 passed.
  • cargo +stable clippy --lib -- -D warnings: passed.
  • cargo +stable fmt --check: passed.

Summary by cubic

Fixes PDFs with image-heavy pages and short text captions incorrectly failing with NeedsOcr. When the initial markdown is blank and fallback extraction yields text from flagged pages, to_markdown now returns that text instead of an error.

  • Image-only pages still return NeedsOcr.
  • When only some pages are flagged, to_markdown extracts all pages in one pass, verifying OCR needs for every flagged page while preserving text from unflagged pages.

Fixes #230.

Written for commit be54416. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file

Reply to a comment to ask cubic a question or push back. It learns from your replies.
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.

View guided diff | Re-trigger cubic

Comment thread src/formats/pdf.rs Resolved
Comment thread src/formats/pdf.rs Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.2.4: a page with an image and a short caption gives "PDF has no extractable text (ImageBased, 1 pages)" and no NeedsOcr

1 participant