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

I have pdf form in which i am filling values using iTextSharp. I wanted to add some more text boxed in the same pdf form. I have written code for that but text boxes are not visible on pdf. If i open pdf with Notepad++ then i can see the text field name and values. that means text boxes are there on pdf but it is not visible.

So could some please help me how do i make text field visible on pdf form?

What I have tried:

C#
try
            {
                iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(SrcFile);
                PdfStamper stamper = new PdfStamper(reader, new FileStream(DestFile, FileMode.Append));

                TextField textname = new TextField(stamper.Writer, new Rectangle(36, 700, 136, 680), "TxtName");
                textname.Text = "softwareid1";
                textname.TextColor = new BaseColor(255, 0, 0);
                textname.BackgroundColor = BaseColor.LIGHT_GRAY;

                TextField textmail = new TextField(stamper.Writer, new Rectangle(36, 660, 136, 640), "TxtMail");
                textmail.Text = "SoftwareId2";
                textmail.Options = TextField.MULTILINE;
                textmail.TextColor = new BaseColor(255, 0, 0);
                textmail.BackgroundColor = BaseColor.LIGHT_GRAY;

                stamper.AddAnnotation(textname.GetTextField(), 1);
                stamper.AddAnnotation(textmail.GetTextField(), 1);
                stamper.AcroFields.GenerateAppearances = true;

                stamper.Close();
            }
            catch (Exception ex)
            { }
Posted

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