Skip to content

fix: include PDF signature appearances in OCR inputs - #6133

Open
xixi-box wants to merge 1 commit into
Tencent:mainfrom
xixi-box:fix/issue-6131-c378635-65456daf
Open

xixi-box wants to merge 1 commit into
Tencent:mainfrom
xixi-box:fix/issue-6131-c378635-65456daf

Conversation

@xixi-box

Copy link
Copy Markdown
Contributor

Fixes #6131

Description

The builtin PDF parser drops visible signature images when they live in a form widget’s appearance stream. Native PDF image extraction reads page content objects, while scanned-page rendering previously left form drawing uninitialized.

Initialize AcroForm rendering and crop visible signature appearances into the existing native PDF image references. Keep searchable page text and use the remaining embedded-image budget for the new crops. Scanned-page JPEGs show the signature in place and retain their existing OCR routing.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

Related Issue

Fixes #6131

Testing

Tests: uv run --project docreader --locked --python 3.10.18 python -m unittest -v docreader.tests.test_pdf_image_sources.PDFImageSourceTest.test_native_pdf_exposes_signature_appearance docreader.tests.test_pdf_image_sources.PDFImageSourceTest.test_forced_scan_renders_signature_appearance.
Result: uv run --project docreader --locked --python 3.10.18 python -m unittest -v docreader.tests.test_pdf_image_sources.PDFImageSourceTest.test_native_pdf_exposes_signature_appearance docreader.tests.test_pdf_image_sources.PDFImageSourceTest.test_forced_scan_renders_signature_appearance — on an archive of HEAD with only the final regression test copied in, exit 1 with four behavioral subtest failures. On the patched tree, exit 0, two tests passed.
Result: uv run --project docreader --locked --python 3.10.18 python -m unittest -v $(printf '%s\n' docreader/tests/test_pdf_*.py docreader/tests/test_source_locator_pdf.py docreader/tests/test_docreader_stream.py docreader/tests/test_parser_routing.py docreader/tests/test_opendataloader_parser.py | sed 's/.py$//; s|/|.|g') — pre-change exit 0 (119 tests run, 3 fixture skips). Patched exit 0 (121 tests run, 3 fixture skips).
Result: uv run --project docreader --locked --python 3.10.18 python -m compileall -q docreader/main.py docreader/parser docreader/tests — exit 0.
Result: git diff --check — exit 0.
Regression coverage: docreader/tests/test_pdf_image_sources.py.

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable (for Go: golangci-lint run --new-from-rev=origin/main ./...)
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, website-docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

Parser-only change.

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>

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.

[Bug]: pdf文件中有数字签名的图片无法解析和ocr识别

1 participant