Skip to content

Add a form whose fields each show one entry of variable text appearances - #48

Merged
MartinThoma merged 1 commit into
mainfrom
text-field-appearances
Dec 2, 2026
Merged

MartinThoma merged 1 commit into
mainfrom
text-field-appearances

Conversation

@MartinThoma

Copy link
Copy Markdown
Member

034-text-field-appearances/text-field-appearances.pdf is a form of three pages with 21 text and choice fields and no appearance streams. Each field shows one entry that decides how its appearance looks, and a label next to it names that entry (ISO 32000-2:2020, 12.7.4.3):

  • the flags Comb (with /MaxLen), Multiline and Combo, and the alignment /Q;
  • the default appearance /DA: a red font, a /DA without a Tf operator, a field without /DA that uses the /DA of the interactive form, and fields without /DA and without a value;
  • the border style /BS (with /W 3 and /S /B, and empty) and the border and background colors of /MK;
  • list boxes with one or two selected options and without /Opt, and a combo box;
  • an old, compressed appearance stream with another /BBox and an /OC entry, which a generated appearance replaces;
  • fields with /MK /R 90 and 270 on pages with the same /Rotate, laid out as viewers write them, so that the text reads upright.

All fields are 200 by 30 points as seen by the reader, and every field is its own widget annotation. /NeedAppearances is true, so that viewers generate the appearances. create_text_field_appearances_pdf.py writes the file without any PDF library and gives the same bytes on every run.

pypdf uses the file to test the appearance streams it generates for these fields.

@MartinThoma
MartinThoma force-pushed the text-field-appearances branch from ec158c4 to 5d7aedb Compare December 2, 2026 07:06
035-text-field-appearances/text-field-appearances.pdf is a form of three
pages with 21 text and choice fields and no appearance streams. Each
field shows one entry that decides how its appearance looks, and a label
next to it names that entry (ISO 32000-2:2020, 12.7.4.3):

* the flags Comb (with /MaxLen), Multiline and Combo, and the alignment /Q;
* the default appearance /DA: a red font, a /DA without a Tf operator, a
  field without /DA that uses the /DA of the interactive form, and fields
  without /DA and without a value;
* the border style /BS (with /W 3 and /S /B, and empty) and the border and
  background colors of /MK;
* list boxes with one selected option, and with two (with the flag
  MultiSelect), without a value and without /Opt, and a combo box;
* an old, compressed appearance stream with another /BBox and an /OC
  entry, which a generated appearance replaces;
* fields with /MK /R 90 and 270 on pages with the same /Rotate, laid out
  as viewers write them, so that the text reads upright.

All fields are 200 by 30 points as seen by the reader, and every field is
its own widget annotation. /NeedAppearances is true, so that viewers
generate the appearances. The file is PDF 1.7, because PDF 2.0 requires
an appearance stream for every widget annotation and deprecates
/NeedAppearances. create_text_field_appearances_pdf.py writes the file
without any PDF library and gives the same bytes on every run.

The README of the sample has a Validation section with what qpdf, the
veraPDF Arlington checker, Firefox, MuPDF, Poppler and Ghostscript
report or show for the file. The README of the repository now asks
for such a section for every PDF that is not written by a typical
generator such as pdfTeX or a word processor.

pypdf uses the file to test the appearance streams it generates for
these fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MartinThoma
MartinThoma force-pushed the text-field-appearances branch from 5d7aedb to 7a1e1bc Compare December 2, 2026 07:53
@MartinThoma
MartinThoma marked this pull request as ready for review December 2, 2026 07:53
@MartinThoma
MartinThoma merged commit ef81aaf into main Dec 2, 2026
2 checks passed
@MartinThoma
MartinThoma deleted the text-field-appearances branch December 2, 2026 07:54
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.

1 participant