Working with XFA Forms
Contents
[
Hide
]
XFA forms can be converted to standard AcroForms so they can be processed with the regular PDF form APIs.
Convert a dynamic XFA form to an AcroForm
- Open the source PDF Document.
- Access the document Form and set the required FormType properties.
- Save the updated PDF Document.
public static void convertDynamicXfaToAcroform(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
document.getForm().setType(FormType.Standard);
document.save(outputFile.toString());
}
}
Convert an XFA form with ignoreNeedsRendering
- Open the source PDF Document.
- Access the document Form and set the required
ignoreNeedsRenderingand FormType properties. - Save the updated PDF Document.
public static void convertXfaFormWithIgnoreNeedsRendering(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
if (!document.getForm().getNeedsRendering() && document.getForm().hasXfa()) {
document.getForm().setIgnoreNeedsRendering(true);
}
document.getForm().setType(FormType.Standard);
document.save(outputFile.toString());
}
}