问题描述
在xdocreport中将odt文件转换为pdf时如何设置加密密码?
我在这里指的是iText
中的PDFWriter.setEncryption
方法.
XDocReport 1.0.4(即将发布)提供fr.opensagres.xdocreport.itext.extension. IPdfWriterConfiguration ,可为您提供自定义iText PDFWriter的功能.这里是设置加密的示例:
org.odftoolkit.odfdom.converter.pdf.PdfOptions options = new PdfOptions();
options.setConfiguration( new IPdfWriterConfiguration()
{
public void configure( PdfWriter writer )
{
writer.setEncryption(...);
}
});
PdfConverter.getInstance().convert( document, out, options );
如果您希望将转换器与report.convert方法一起使用,则必须这样做:
org.odftoolkit.odfdom.converter.pdf.PdfOptions pdfOptions = ...
Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.ODFDOM).subOptions(pdfOptions);
IXDocReport report = ...
report.convert(context, options, out);
您可以在 XDocReport Wiki 中找到这些信息.. >
How to set encryption password while converting odt file to pdf in xdocreport?
I am referring to PDFWriter.setEncryption
method in iText
here.
XDocReport 1.0.4 (which will soon released) provides fr.opensagres.xdocreport.itext.extension.IPdfWriterConfiguration which gives you the capability to customize the iText PDFWriter. Here a sample which set encryption :
org.odftoolkit.odfdom.converter.pdf.PdfOptions options = new PdfOptions();
options.setConfiguration( new IPdfWriterConfiguration()
{
public void configure( PdfWriter writer )
{
writer.setEncryption(...);
}
});
PdfConverter.getInstance().convert( document, out, options );
If you wish to use the converter with the report.convert method, you must do like this :
org.odftoolkit.odfdom.converter.pdf.PdfOptions pdfOptions = ...
Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.ODFDOM).subOptions(pdfOptions);
IXDocReport report = ...
report.convert(context, options, out);
You can find those info in the XDocReport wiki.
这篇关于在xdocreport中为pdf设置加密密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!