Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

itextsharp using livecycle form with dynamic table


Former Community Member
Hello all, after searching Google for the past two days and not able to find any relevant information, hence this post.

Some background:

1) Created a pdf form using Adobe Livecycle designer 9.

2) It is a dynamic form with textboxes and a table configured to repeat rows dynamically.

3) Testing form using xml data within designer works just fine.


Need to populate form dynamically using data from database.


Found iTextSharp (free assembly) which assists with populating existing pdf form.


This assembly works without any issue when populating textfields (see sample code below). The problem I am facing is with the dynamic table where in I am not able to reference rows greater than 1. Since the pdf template contains a table with just one row referencing the first row using acrofield works.

I was under impression since this is a dynamic table with repeat enabled, in asp.net if I referenced row2 onwards the table would grow automatically. Which I have come to realize is not going to be possible.

So I am looking for ideas on how I can accomplish this. I wish this could have been a fixed row table then reference rows would have been easier. However in this situation the table has to be dynamic.

Any ideas thoughts would be appreciated.

Below is my sample code:

PdfStamper ps = null;

try {

// read existing PDF document

PdfReader r = new PdfReader(

// optimize memory usage

new RandomAccessFileOrArray(Request.MapPath("itext.pdf")), null


ps = new PdfStamper(r, Response.OutputStream);

// retrieve properties of PDF form w/AcroFields object

AcroFields af = ps.AcroFields;

// fill in PDF fields by parameter:

// 1. field name

// 2. text to insert

af.SetField("txtCompany", "Company name");

af.SetField("txtDateDepartLocation", "date depart location");

af.SetField("txtDate","test date");

af.SetField("txtServiceNumber", "Service number");

af.SetField("Table2.Row1.Cell1", "1test");  this works

//doesnt work!!!

af.SetField("Table2.Row2.Cell1", "1test");

af.SetField("Table2.Row3.Cell1", "1test");

// make resultant PDF read-only for end-user

ps.FormFlattening = true;

// forget to close() PdfStamper, you end up with

// a corrupted file!



catch { }

finally { if (ps != null) ps.Close(); }


0 Replies