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

Do you need to process or display PDF files?

Find out why you should be using IDRSolutions software

A 6 Step guide on ‘How to create expandable XFA form in Livecycle Designer’

1 min read

At IDR Solutions we spend alot of time working with XFA in our Java PDF Library. I have spent a lot of time working with XFA and thought it might be useful to take you through how you can go about creating a simple expandable XFA form using the livecycle designer xml code.

Step 01)

Create a subform called “group” and insert another subform called “student” into it.

so you will end up a XML code similar to it

<subform w=”576pt” name=”group” layout=”tb”>
<subform name=”student” w=”100mm” layout=”tb”/>
</subform>

(ignore other attributes except name at the moment)

Step 02)

Insert two fields to student subform and name as username , coursename.

<subform w=”576pt” name=”group” layout=”tb”>
<subform name=”student” layout=”lr-tb”>
<field name=”username” w=”62mm” h=”9mm”>
……..//other field specification goes here
</field>
<field name=”username” w=”62mm” h=”9mm”>
……..//other field specification goes here
</field>
<keep intact=”contentArea”/>
</subform>
</subform>

Step 03)

Add a button named “InsertStudent” just after subform named as “group”

……………
<subform w=”576pt” name=”group” layout=”tb”>
<field name=”InsertStudent” w=”28.575mm” h=”6mm”>
……….//other button related stuff goes here
</field>
<subform name=”student” layout=”lr-tb”>

Step 04)

Add a javascript click event to the button so clicking the button will add student instances ( make sure to prefix an underscore before student.addinstance(1); script)

<field …….>
<event activity=”click” name=”event__click”>
<script contentType=”application/x-javascript”>
_student.addInstance(1);
</script>
</event>

Step 05)

Change the occur tag attributes of student subform to accept multiple occur capabilities

<subform name=”student” layout=”lr-tb”>
<occur max=”-1″/> …..

Step 06)

Save as a PDF file and try clicking insertstudent labelled button, you will find the expansion of the student form

After these steps you will get a form like the one listed in the screen shot below.

xfaaddition
The final result after following the guide to create expandable XFA form in Livecycle Designer

Hopefully you have found this guide useful, let us know what XFA guides you would like to see in the future.



Our software libraries allow you to

Convert PDF files to HTML
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
Read and write HEIC and other Image formats in Java
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