我正在使用xDocReport从Docx和Odt文件生成pdf,除了IPdfWriterConfiguration之外,一切都很好,除了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();
}
答案 0 :(得分:1)
添加此maven依赖项为我解决了这个问题
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId>
<version>1.44</version>
</dependency>