As I mentioned in my previous article ‘XFA components structure and finding x,y coordinates’ , XFA objects are categorized into dynamic form components and static draw components.
In this article the discussion will be focusing on static draw components such as drawing texts and other shape components and locations.
Usually the x.y coordinates of form components relies on x,y.minx, miny, w and h tags. In addition to those tags draw components also have a tag called anchortype which defines the origination point of the components. Default is TopLeft (top left hand corner) and other options are TopCenter, TopRight, middleLeft, middleCenter, middleLeft, BottomLeft, BottomCenter and BottomRight. However It is recommended not to use negative values in renderers.
The “arc” tag is used to draw arcs, circles and ovals in XFA forms. Usually if sweepAngle is not defined only circle displays on the screen. In combination with sweepAngle and width attribute you can define it whether it is a circle. eclipse or arc.
Images in XFA could be either embedded or has a url of a image location. If it is embedded then it would be in the form of base64 encoded string. If you are a java programmer you can use the code shown below to get bytes representation.(please ignore this bit if you already know how to handle base64 string to data bytes)
byte  dataBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary(imageString);
Rectangle and Line:
PDFs usually calculate its x,y coordination from bottom left corner of the page but XFA forms calculate from top left corner of the page. This is an important factor to be considered when you try to utilize the drawings in Rectangle and lines because both start from top and end in base.
Usually lines are drawn from left top to bottom right if they contain width (not thickness). if lines have slope attribute with value of “/” then it should be drawn from top right to left bottom.
Other important factors:
Do not rely on name attribute of draw tags to define what type of components that is. Images can be defined with “imageEdit” tag under “UI” or just “image” tags under “defaultUI”. Images are growable according to its width unless “aspect” is set to actual.
This post is part of our “XFA Articles Index” in these articles, we aim to help you understand XFA.
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Find out more about our software for Developers
|Convert PDF to HTML5 or SVG|
|Convert AcroForms and XFA to HTML5|
|Java PDF SDK for working with PDF files|