XFAFlattener构造函数似乎做了System.exit(0)

时间:2015-06-04 20:56:35

标签: java itext

我正在尝试使用XFAFlattener(iText 5.4.5)压平XFA表单。我的代码几乎与FillAndFlatten示例完全相同。在调用此方法之前,LicenseKey已成功加载

private void fillAndFlattenForm(File xmlFile, File inputPdf, File outputPdf) throws Exception {
    PdfReader inputPdfReader = null;
    PdfReader outputPdfReader = null;
    PdfStamper stamper = null;
    InputStream inputPdfStream = null;
    InputStream xmlFileStream = null;
    ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
    OutputStream fileOutputStream = null;
    try {
        // fill the inputPdf using the XML data
        inputPdfStream = new FileInputStream(inputPdf);
        inputPdfReader = new PdfReader(inputPdfStream);
        stamper = new PdfStamper(inputPdfReader, byteOutputStream);
        AcroFields form = stamper.getAcroFields();
        XfaForm xfa = form.getXfa();
        xmlFileStream = new FileInputStream(xmlFile);
        xfa.fillXfaForm(xmlFileStream);
        stamper.close();
        // the inputPDF has been filled and is in memory in the byteOutputStream; flatten it now
        Document document = new Document();
        fileOutputStream = new FileOutputStream(outputPdf);
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
        XFAFlattener xfaf = new XFAFlattener(document, writer);
        outputPdfReader = new PdfReader(byteOutputStream.toByteArray());
        xfaf.flatten(outputPdfReader);
        document.close();
    } finally {
        close(stamper);
        IOUtil.close(xmlFileStream);
        close(inputPdfReader);
        IOUtil.close(inputPdfStream);
        close(outputPdfReader);
        IOUtil.close(byteOutputStream);
        IOUtil.close(fileOutputStream);
    }
}

我看到的情况是,当我的代码到达此行时

XFAFlattener xfaf = new XFAFlattener(document, writer);

它刚刚退出。抛出没有异常,代码也没有继续。此过程返回的错误代码为0。

我已确认表格填写正常。

有关可能出现的问题的任何想法,或者我可以采取哪些措施来进一步诊断此问题?提前致谢

0 个答案:

没有答案