Reputation: 815
I tried to fill my pdf using iTextsharp library.I took reference from this tutorial fill pdf using iTextsharp. But when I tried this example with my pdf file it showed nothing. When I read my pdf file in pdf reader it contains null.
string pdfTemplate = @"c:\authform.pdf";
// create a new PDF reader based on the PDF template document
PdfReader pdfReader = new PdfReader(pdfTemplate);
In this I get null when I read my pdf template.Is there some special format in which the pdf template should be so that it can work with this example.
Upvotes: 2
Views: 533
Reputation: 3330
If you check the tutorial there are two examples.
one is to read fields from existing pdf. second one is to print data to pdf.
The following is the way to print data to pdf.
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));
AcroFields pdfFormFields = pdfStamper.AcroFields;
// set form pdfFormFields
// The first worksheet and W-4 form
pdfFormFields.SetField("f1_01(0)", "1");
pdfStamper.Close();
Upvotes: 1