I need to be able to form Fill a PDF document after i have inserted a page(with form fields in it) , is this possible , see the code below , it is still producing a document with no fields filled in it from the incomming XML ...
string inputfile1 = GetResource("PFB6.pdf");
// pdf file from which pages will be insterted
string inputfile2 = GetResource("Applicant.pdf");
//// Pdf file to which pages will be inserted
FileStream inStream1 = File.Open(inputfile1, FileMode.Open, FileAccess.Read, FileShare.Read);
// Stream of Pdf file for pages
FileStream inStream2 = File.Open(inputfile2, FileMode.Open, FileAccess.Read, FileShare.Read);
HttpResponse response = HttpContext.Current.Response;
////Example 1 :insert page 2 pages at i postition
PdfFileEditor pdfEditor = new PdfFileEditor();
int location = 1;
int[] pages = new int[] { 1 };
//generate new Pdf file output stream
MemoryStream outStream = new MemoryStream();
pdfEditor.Insert(inStream1, location, inStream2, pages, outStream);
//---Formfill XML
Form form = new Form(outStream, "output.pdf");
string xml = GetResource("XML.xml");
//Open an existed fdf file.
System.IO.FileStream xmlInputStream = new FileStream(xml, FileMode.Open);
//Export all the pdf fields' value into the fdf file.
form.ImportXml(xmlInputStream);
form.Save();
xmlInputStream.Close();
// create a byte array that will hold the output pdf
byte[] outBuf = outStream.GetBuffer();
// specify the duration of time before a page,cached on a browser expires
response.Expires = 0;
// Specify the property to buffer the output page
response.Buffer = true;
// Erase any buffered HTML output
response.ClearContent();
//Add a new HTML header and value to the response sent to the client
response.AddHeader("content-disposition", "inline; filename=" + "output.pdf");
// Specify the HTTP content type for response as Pdf
response.ContentType = "application/pdf";
// Write specified information of current HTTP output to Byte array
response.BinaryWrite(outBuf);
// close the output stream
outStream.Close();
//end the processing of the current page to ensure that no other HTML content is sent