Click here to Skip to main content
15,902,447 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am adding form fields inside a loop with different names but I am not getting the expected value. Here is my code:
C#
PdfReader reader = null;
PdfStamper stamper = null;
for (int i = 1 ; i <= 2; i++)
{
reader = new PdfReader(file);
stamper = new PdfStamper(reader, memoryStream);
PdfFormField acctNum = PdfFormField.CreateTextField(stamper.Writer, false, false, 50);
acctNum.SetWidget(new iTextSharp.text.Rectangle(383, 746, 521, 728), PdfAnnotation.HIGHLIGHT_INVERT);
acctNum.Flags = PdfAnnotation.FLAGS_PRINT;
acctNum.FieldName = "ACCT_NUM_" + i;
stamper.AddAnnotation(srcAcctNum, 1);
stamper.Writer.CloseStream = false;  
stamper.FormFlattening = false;
stamper.Close();
reader.Close();
}

The loop runs twice, henceforth I should get form field names as ACCT_NUM_1 and ACCT_NUM_2. But I am getting form field names as ACCT_NUM_1 and ACCT_NUM_1(2). Could you please point out the mistake I am making here.
Posted
Comments
Prasad Khandekar 31-May-13 9:34am    
Hello Sanket,

Please have a look at this sample (http://itextpdf.com/examples/iia.php?id=142).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900