tomatoeshift
tomatoeshift

Reputation: 485

Why is PDF form information stored on both 'Root.AcroForm.Fields' & 'Root.Pages.Kids[0].Annots'

If I update the value of a form in either of these locations, both are affected. Why are they stored twice?

When updating these forms, is one preferred to be used over the other one? (I'm using Python library pdfrw)

'/Root':{
        '/AcroForm': {'/Fields': [(10, 0), (11, 0)] }, 
        '/Pages':   { '/Kids': [ {'/Annots': [(10, 0), (11, 0)] }] }
        }

EDIT

Root.AcroForm.Fields Root.Pages.Kids[0].Annots enter image description here

Upvotes: 0

Views: 463

Answers (1)

mkl
mkl

Reputation: 95918

The AcroForm dictionary references all abstract form fields (directly or indirectly) to allow immediate access to all fields of a document.

Each abstract form field may have any number of widget annotations (except signature fields with at most one annotation).

Widget annotations are for displaying the form field contents. Thus, they must be attached to the page they respectively are displayed upon. So they are referenced from the Annots of the respective page.

If a form field has no widget annotation, you cannot find it from any page.

If a form field has exactly one widget annotation, you can usually find it from exactly one page, the page that annotation is on. In this case the form field object and the widget annotation object may be merged into a single object.

If a form field has more widget annotations, you can usually find it on one or more pages, depending on whether all those annotations are on the same or one different pages.


Thus,

Why are they stored twice?

They are not stored twice, each form field is stored only once, in one PDF object. But that form field object can usually be reached from multiple locations in the object model, from the global AcroForm object and from the Annots of each page that form field has a widget on.

Upvotes: 3

Related Questions