Set encryption password for pdf in xdocreport

寵の児 提交于 2020-01-06 13:30:27

问题


How to set encryption password while converting odt file to pdf in xdocreport?

I am referring to PDFWriter.setEncryption method in iText here.


回答1:


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.



来源:https://stackoverflow.com/questions/21871887/set-encryption-password-for-pdf-in-xdocreport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!