1

I have a PDF with form fields created with Acrobat DC by my customer. Using Python pikepdf I'm filling those fields programmatically. The strange issue is that some fields are filled, others not. I checked and double-checked with Acrobat DC: All fields have the exact same Text Field Properties, with the names obviously being unique. The Python code addresses the fields with their correct name. So I suspect that the problem might be related to the way my customer created the fields. Using Acrobat DC I deleted the offending fields and created brand new ones with the same Text Field Properties as the fields that show up as filled in -- to no avail.

Now I checked the pikepdf-generated PDF with Acrobat Reader, and all filled-in fields display their value, sigh! However, none of the Linux PDF viewers displays the content of the offending fields while displaying the content of some other fields. I tried Okular, Atril, the document viewer of XFCE4, and LibreOffice Draw. This seems to indicate that the issue on the Acrobat side of things. Any ideas?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • You may want to share the pdf before and after attempted fill-in for analysis. – mkl Jan 30 '20 at 19:28
  • 1
    It sounds like pikepdf is not generating the PDF appearances for the field values. Some PDF viewers, like Adobe Reader will create appearances when there aren't any. Most viewers won't though. That accounts for why some viewers show the field values but others don't. This will be particularly true when a field property have a format applied to it... like a date. – joelgeraci Jan 30 '20 at 20:29

2 Answers2

0

@joelgeraci : You are right, pikepdf doesn't generate appearance streams. The strange thing is that a viewer like the XFCE4 Document Viewer displays the filled-in values for some fields, but not for others. Here's part of a page dump generated by pikepdf:

<pikepdf.Dictionary(type_="/Page")({
  "/Annots": [ {
    "/DA": "/HeBo 14 Tf 0 g",
    "/F": 4,
    "/FT": "/Tx",
    "/Ff": 12582912,
    "/MK": {

    },
    "/P": <.get_object(785, 0)>,
    "/Q": 1,
    "/Rect": [ Decimal('134.783'), Decimal('432.837'), Decimal('205.463'), Decimal('458.588') ],
    "/StructParent": 201,
    "/Subtype": "/Widget",
    "/T": "Number_01",
    "/Type": "/Annot"
  }, {
    "/DA": "/HeBo 14 Tf 0 g",
    "/F": 4,
    "/FT": "/Tx",
    "/Ff": 12582912,
    "/MK": {

    },
    "/P": <.get_object(785, 0)>,
    "/Q": 1,
    "/Rect": [ Decimal('590.089'), Decimal('430.645'), Decimal('660.768'), Decimal('455.76') ],
    "/StructParent": 202,
    "/Subtype": "/Widget",
    "/T": "Units_01",
    "/Type": "/Annot"
  } ],
...
})>

While field "Number_01" is shown as filled-in, field "Units_01" is not, although both do not have an appearance stream. Yet other fields do have an appearance stream and the filled-in value is displayed too, although pikepdf can't update appearance streams. I'm also wondering why Acrobat DC creates appearance streams for some fields, but not for others.

0

Solution

I stupidly passed an INT to pikepdf when filling the fields; passing a string solved the problem. What is more: The Linux viewers do not require the 'NeedAppearances' flag to display the filled-in values, while Acrobat Reader does need this flag.