Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hey everyone, im new to iTextSharp, i wanted to have a new pdf file by update the existing template pdf, and i followed this tutorial
http://simpledotnetsolutions.wordpress.com/2012/04/08/itextsharp-few-c-examples/

i have a problem with fillPDFForm()
this is my code:
C#
public string P_InputStream = "template/test.pdf";
public string P_OutputStream = "output/test.pdf";

 public template()
 {
     InitializeComponent();
 }
 
private void template_Load(object sender, EventArgs e)
 {
     string formFile = P_InputStream;
     string newFile = P_OutputStream;
     PdfReader reader = new PdfReader(formFile);
     using (PdfStamper stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Create)))
     {
         AcroFields fields = stamper.AcroFields;

         // set form fields
         fields.SetField("customerName", "John Doe");
         fields.SetField("Address", "xxxxx, yyyy");
         fields.SetField("Test", "12345");

         // flatten form fields and close document
         stamper.FormFlattening = true;
         stamper.Close();
     }
 }


after the form load, the data inside the pdf file is still the same, din't update. perhaps i dint create the pdf file properly? this is how i did:
1. i open a open office writer
2.Insert Fields>under Variables tab>choose "Set Variable" for Type and "General for Format
3.type the name, and click Insert.
4. File>Export as PDF

am i doing this right?
Posted

1 solution

nothing wrong with the code, is the way how we create the pdf file, follow this tutorial:

http://michaellenahan.blogspot.com/2008/08/server-side-pdf-form-generation-with.html[^]
 
Share this answer
 

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