Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm itextsharp
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;
 
         // 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 5-Dec-12 22:32pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 BillWoodruff 330
2 OriginalGriff 310
3 Shweta N Mishra 244
4 Mathew Soji 225
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,638
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,710


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 6 Dec 2012
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