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:
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;
fields.SetField("customerName", "John Doe");
fields.SetField("Address", "xxxxx, yyyy");
fields.SetField("Test", "12345");
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?