fix: initialize form rendering for fillable PDFs (#240)#241
Merged
fix: initialize form rendering for fillable PDFs (#240)#241
Conversation
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.
Summary
Fixes #240 — Fillable PDF form fields (text inputs, checkboxes, radio buttons, dropdowns) were not rendered in page images, causing empty extraction results.
Root Cause
pypdfium2's
page.render(may_draw_forms=True)(the default) requiresPdfDocument.init_forms()to be called first to initialize the form rendering engine. Without this call, AcroForm content is silently omitted from rendered images — so OCR/extraction only sees the blank form template.Changes
lib/idp_common_pkg/idp_common/ocr/service.py— Addedpdf_document.init_forms()afterpdfium.PdfDocument(file_content)inprocess_document()(Pattern 2 pipeline OCR)patterns/unified/src/bda_processresults_function/index.py— Addedpdf_document.init_forms()afterpdfium.PdfDocument(pdf_content)increate_pdf_page_images()(Pattern 1 BDA thumbnails)lib/idp_common_pkg/tests/unit/ocr/test_ocr_service.py— Added regression testtest_process_document_calls_init_forms_for_fillable_pdfsCHANGELOG.md— Added fix entry under [Unreleased]Risk Assessment
Very low risk —
init_forms()is a no-op for non-fillable PDFs. Themay_draw_forms=Truedefault was already set; this fix simply enables the feature that was intended to work.Testing
make test-cicd)