It 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.
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.
Latest posts by suda (see all)
- Lanczos3 algorithm as a way to produce better image downscaling - January 5, 2016
- How to read Tiff images in Java - August 13, 2015
- How to generate smaller PNG files in Java - July 1, 2015
- PDF XFA – Sending data as an Email - February 24, 2015
- PDF Coons Shading – find color value of given point - January 27, 2015