العمل مع نماذج XFA

يمكن تحويل نماذج XFA إلى AcroForms قياسية حتى يمكن معالجتها باستخدام واجهات برمجة تطبيقات نماذج PDF العادية.

تحويل نموذج XFA الديناميكي إلى AcroForm

  1. افتح PDF المصدر Document.
  2. انتقل إلى Document Form وعيّن المطلوب FormType الخصائص.
  3. احفظ ملف 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());
    }
}

تحويل نموذج XFA باستخدام ignoreNeedsRendering

  1. افتح PDF المصدر Document.
  2. انتقل إلى Document Form وعيّن المطلوب ignoreNeedsRendering و FormType الخصائص.
  3. احفظ ملف 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());
    }
}