【发布时间】:2015-07-03 06:56:26
【问题描述】:
我正在使用 xDocReport 从 Docx 和 Odt 文件生成 pdf,除了 IPdfWriterConfiguration 在转换发生时似乎没有被识别或调用之外,一切都很好。
PdfOptions pdfOptions = PdfOptions.create();
pdfOptions.setConfiguration(new IPdfWriterConfiguration() {
// This is never called
public void configure(PdfWriter writer) {
try {
writer.setEncryption("Hello".getBytes(), "Hello".getBytes(),
PdfWriter.ALLOW_COPY,
PdfWriter.STANDARD_ENCRYPTION_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA);
writer.createXmpMetadata();
} catch (DocumentException ex) {
throw new RuntimeException(ex);
}
}
});
Options options = Options.getTo(ConverterTypeTo.PDF).subOptions(pdfOptions);
OutputStream out = new FileOutputStream(tempPdfFile);
try {
report.convert(context, options, out);
} finally {
out.close();
}
【问题讨论】:
-
似乎 iText 使用了一个名为 bountycastle 的库进行加密,并且由于 bountycastle 最新版本破坏了 iText 支持,我不得不使用该库的较低版本才能使其正常工作。似乎 xDocReport 或更具体地说,iText 使用一个名为 bountycastle 的库进行加密,由于 bountycastle 最新版本打破了 iText 支持,我不得不使用该库的较低版本才能使其正常工作according to this thread
标签: java pdf itext xdocreport