Draw Components in XFA

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.

ARC:

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.

Image:

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.

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 (Twitter, Facebook and Google+) or the  Blog RSS.

Related Posts:

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.
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=""> <s> <strike> <strong>