// Currently iText xfdf implementation works with the fields in the following way: when the <value> tag with text // contents is found, it is considered to be the value of the field. All other <value> tags are ignored. public void listInSetField(String dest) { String pdfForm = sourceFolder + "simpleRegistrationForm.pdf"; String xfdf = sourceFolder + "list_register.xfdf"; PdfDocument pdfDocument = new PdfDocument( new PdfReader(new FileStream(pdfForm, FileMode.Open, FileAccess.Read)), new PdfWriter(new FileStream(dest, FileMode.Create))); XfdfObjectFactory factory = new XfdfObjectFactory(); XfdfObject xfdfObject = factory.CreateXfdfObject(new FileStream(xfdf, FileMode.Open, FileAccess.Read)); xfdfObject.MergeToPdf(pdfDocument, pdfForm); pdfDocument.Close(); }
// Currently iText xfdf implementation works in the following way: // data from Pdf form could be received as file with the XFDF file extension. public void createXfdf(String dest) { String pdfDocumentName = "createXfdf.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(new FileStream (sourceFolder + pdfDocumentName, FileMode.Open, FileAccess.Read))); XfdfObjectFactory factory = new XfdfObjectFactory(); XfdfObject xfdfObject = factory.CreateXfdfObject(pdfDocument, pdfDocumentName); xfdfObject.WriteToFile(dest); pdfDocument.Close(); }