Skip to content

fix(pdf): warn when host fonts leave page text unpainted - #5009

Open
Yun-0000 wants to merge 1 commit into
docling-project:mainfrom
Yun-0000:fix/pdf-warn-unpainted-text
Open

Yun-0000 wants to merge 1 commit into
docling-project:mainfrom
Yun-0000:fix/pdf-warn-unpainted-text

Conversation

@Yun-0000

Copy link
Copy Markdown

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

See #4995.

The default PDF backend paints non-embedded fonts with host fonts. A host with no match leaves the page image blank, so layout and table detection can drop the text, and nothing said so. This does not make the render independent of the host. It warns once per document when visible text cells contain almost no ink, and the installation guide lists the font packages and DOCLING_PARSE_FALLBACK_FONT.

Review evidence:

Before: get_page_image() on a page whose text cells sit on a blank image logged nothing.
After: the same call logs one warning that names DOCLING_PARSE_FALLBACK_FONT. A second call does not log again. Ink inside the text cells, and a crop, do not warn. A real render of tests/data/pdf/invisible_text_layer.pdf on this host has an ink fraction of 0.25, so it does not warn.

Passed:

  • uv run pytest tests/test_docling_parse_missing_font.py on main: 2 failed (test_unpainted_text_warns_once, test_a_crop_does_not_warn_before_the_full_page), 1 passed (test_ink_inside_text_cells_does_not_warn).
  • Same file after the change: 3 passed.
  • uv run pytest tests/test_backend_docling_parse.py tests/test_docling_parse_missing_font.py: 37 passed.
  • make validate: passed.

Failed:

  • none after the change.

Not run:

  • make test. No PDF reference files were regenerated. This host has DejaVu fonts, so the no-font render itself was not reproduced here.

docling-parse draws non-embedded fonts with host fonts. A host with
no match leaves the page image blank, and layout can drop the text.
Warn once per document and document the font packages.

Signed-off-by: Yun. <fangyun1008@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @Yun-0000, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working documentation Improvements or additions to documentation pdf PDF issue (except docling-parse) pdf parsing PDF issue related to docling-parse tests issue related to changes needed in the tests labels Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 3833103aa4. The analysis read the diff only. It did not run code from this pull request.

The PR adds a one-time warning in the docling-parse backend. It fires when get_page_image() returns a full-page image with almost no dark pixels inside the visible text cells, which means no host font painted the text. It also adds a font-install section to the installation guide, a line in the usage skill, and a new test file.

Topic labels added: bug, pdf, pdf parsing, documentation, tests.

CI safety: no concern found. A maintainer must still approve CI.

1 related pull request(s) in the same code
PR State Signal Assessment
#4833 open changes the same code related: Both PRs edit docling/backend/docling_parse_backend.py. PR 4833 adds a password-protected PDF error in the load path. This PR adds a font-paint warning in page rendering. The changes do not conflict in purpose.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 25, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI first review (advisory): no blocker found

This review covers the full diff at 3833103aa4. It read the code and did not run it.

Checked the text ink fraction check, the single warning state per document backend, and the test coverage for blank and drawn pages with no issues found.

A maintainer makes the merge decision. This review never approves the pull request.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.48148% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/backend/docling_parse_backend.py 81.48% 5 Missing and 5 partials ⚠️

📢 Thoughts on this report? Let us know!

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

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working documentation Improvements or additions to documentation pdf parsing PDF issue related to docling-parse pdf PDF issue (except docling-parse) tests issue related to changes needed in the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant