Reputation: 3480
I'm facing a problem when filling a PDF form using iTextSharp, I'm using the following code to fill the PDF form:
PdfReader pdfReader = new PdfReader(Properties.Resources.ConfirmationFees);
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(folderPath + "\\" +fileName, FileMode.Create));
AcroFields pdfFFields = pdfStamper.AcroFields;
pdfFFields.SetFieldProperty("Text1", "textsize", 10.0f, null);
pdfFFields.SetField("Text1", serialNumber.ToString("D6") + "№");
pdfStamper.FormFlattening = false;
// close the pdf
pdfStamper.Close();
When I open the PDF, I have to select the textField and go to Properties, select border color or fill color, and click on "No Color". or just simply add a character to the textField.
I've tried to set the border and background color of the textField to null, but without luck.
So, how can I solve this problem without doing the mentioned way?
Upvotes: 0
Views: 2739
Reputation: 77528
How did you create your form? If with Open/Libre Office, then the forms are a little bit crappy. You may need to add this line:
pdfFFields.setGenerateAppearances(true);
In your specific C# snippet, that would be:
pdfFFields.GenerateAppearances = true;
See also:
If this doesn't solve your problem, you need to tell us which version of iTextSharp you're using. If it's older than 5.5.1, please upgrade.
Upvotes: 2