Skip to content

Initialize PDFium's form environment so filled AcroForm fields render in to_image() - #1376

Merged
jsvine merged 1 commit into
jsvine:developfrom
cycsmail:fix/acroform-init-forms-1367
Jun 17, 2026
Merged

jsvine merged 1 commit into
jsvine:developfrom
cycsmail:fix/acroform-init-forms-1367

Conversation

@cycsmail

@cycsmail cycsmail commented Jun 15, 2026

Copy link
Copy Markdown

Fixes #1367.

get_page_image opens the PDFium document but never calls init_forms(), so any filled AcroForm widget content is missing from the bitmap that Page.to_image() produces. Adding the call right after the document is opened (and before the page is loaded) fixes it; it's a no-op for PDFs that have no form, so non-form rendering is unchanged.

Added a regression test reusing the existing federal-register-2020-17221.pdf fixture: it renders page 0 and asserts that a crop over a filled form field has non-white pixels. Without the fix that region is blank (0 non-white pixels) and the test fails; with it the region has content (945) and it passes. The tests/test_display.py suite passes (17 tests) and black/isort/flake8 are clean.

@cycsmail
cycsmail force-pushed the fix/acroform-init-forms-1367 branch from 05d2094 to 14fe1d5 Compare June 16, 2026 04:06
@cycsmail cycsmail changed the title Fix filled AcroForm widget content missing from to_image() output Initialize PDFium's form environment so filled AcroForm fields render in to_image() Jun 16, 2026
@jsvine

jsvine commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Thanks @cycsmail — this seems like a helpful and concise fix, as well as a useful test. Much appreciated. Merging to develop.

@jsvine
jsvine merged commit 4cf8241 into jsvine:develop Jun 17, 2026
6 checks passed
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.

2 participants