suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

Do you need to display PDF Forms in a Browser?

Find out how FormVu can convert PDF Forms into HTML5

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

1 min read

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.

FormVu allows you to

Use PDF Forms in the Web Browser
Integrate PDF Forms into Web Apps
Parse PDF forms as HTML5
suda Senior Java EE Develope specialises in Pdf forms , Fonts, application servers and Image manipulation, meditates in spare time.

How to insert an image into a PDF

Recently, we released JPedal 2023.07 which contains the ability to insert images into PDF files. All you need is a copy of JPedal, a...
Jacob Collins
18 sec read