XFA 양식 작업

XFA 양식은 표준 AcroForms로 변환되어 일반 PDF 양식 API로 처리될 수 있습니다.

동적 XFA 양식을 AcroForm으로 변환

  1. 원본 PDF Document를 여세요.
  2. 문서 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());
    }
}

ignoreNeedsRendering을 사용하여 XFA 양식 변환

  1. 원본 PDF Document를 여세요.
  2. 문서 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());
    }
}