How to draw PDF XFA Forms accurately (in your viewer)

XFA_iconIt is a bit of complex task if any attempt is made to try and display XFA forms (by following the XFA specification) in a custom viewer rather than adobe life-cycle. Either you are expected to have a similar functionality of the HTML parser which should be intelligent enough to draw components recursively or you should have a custom parser.

Subforms in XFA may contain one or many subforms and each of them may contain individual components that could be either container (containing subforms, exclusion groups, area, subformset) or widgets (Rectangle, text, arc, input text, checkbox, choice-list and so on).

Every subform’s x,y coordination depend on previous and parent elements of it; its height depends on the height and width of the child elements if H attribute or min H attribute is not specified. In such a complex situation the form height and x,y coordination should be in memory or should be injected as attribute in order to render them accurately, (in my personal opinion injecting data as an attribute consume much less memory).

Datasets also have a major influence on the way the form is rendered, because form occurrences (number of forms) have to be multiplied based on bind data (be aware that bind names play major role rather than typical name attribute of subform node).

Forms do have page breaks that render form and it components in different pages, in addition to that components of a single form can be split into multiple pages if its x,y location exceeds the allowed height of content area of PageArea element.

One of the recommended way of handling such a scenario described above is to draw the form coordination in memory or as attributes and splitting them later based on page breaks, data sets and content area overflow. Margins (left, right, bottom and top) also need to be considered on the stage of rendering.

Possible subform layouts such as Positioned, Top to bottom. left to right, right to left, table and row have to be considered in finding relevant heights of given subform. The calculation may vary one to another.

Dynamic XFA forms contains javascript (a real beast in XFA layout)  that determine visibility and total occurrence of individual forms.

It is worth considering all of these list of checkpoints prior to positioning subforms in your viewer. If you need more information checkout some of our blog posts that analyze some concepts deeper. You can find the links here. http://blog.idrsolutions.com/2013/09/xfa-articles-index-understanding-xfa/.

This post is part of our “XFA Articles Index” in these articles, we aim to help you understand XFA.

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (TwitterFacebook and Google+) or the  Blog RSS.

Ebook Page Link

The following two tabs change content below.

suda

Java EE developer at IDRSolutions
Suda is the Senior Java EE Developer at IDR Solutions, and specialises in XFA, Fonts, True-Type Fonts, application servers and conversions. He is a keen science-fiction fan in his spare time.

Related Posts:

suda

About suda

Suda is the Senior Java EE Developer at IDR Solutions, and specialises in XFA, Fonts, True-Type Fonts, application servers and conversions. He is a keen science-fiction fan in his spare time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>