Set encryption password for pdf in xdocreport

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

I mean the method PDFWriter.setEncryptionin iTexthere.

0
source share
1 answer

XDocReport 1.0.4 (which will be released soon) provides fr.opensagres.xdocreport.itext.extension. IPdfWriterConfiguration , which gives you the ability to customize iText PDFWriter. Here's a sample that sets up 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 want to use the converter with the report.convert method, you must do the following:

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 this information in the XDocReport wiki .

+2
source

All Articles