Click here to Skip to main content
13,055,490 members (52,572 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I am adding form fields inside a loop with different names but I am not getting the expected value. Here is my code:
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;

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 31-May-13 2:33am
Prasad Khandekar 31-May-13 9:34am
Hello Sanket,

Please have a look at this sample (

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 31 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100