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

Draw Components in XFA

1 min read

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.

Do you need to solve any of these problems?

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

Leave a Reply

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

IDRsolutions Ltd 2022. All rights reserved.