Click here to Skip to main content
11,790,613 members (61,057 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# itextsharp

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 at 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
0 OriginalGriff 1,154
1 Maciej Los 825
2 KrunalRohit 686
3 ppolymorphe 660
4 CPallini 621

Advertise | Privacy | Mobile
Web03 | 2.8.1509028.1 | Last Updated 31 May 2013
Copyright © CodeProject, 1999-2015
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