Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# itextsharp
Hi,
 
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;
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 31-May-13 3:33am
Comments
Prasad Khandekar at 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)



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