0

I'm using xDocReport to generate pdfs from both Docx and Odt files, everything works great except for the IPdfWriterConfiguration that doesn't seem to get recongnized or called when the conversion happens.

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();
}
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
soaP
  • 101
  • 5
  • It seems that iText uses a library, called bountycastle for encryption and since bountycastle latest version breaks iText support I had to use a lower version of this library in order for this to work.It seems that xDocReport or more specifically iText uses a library, called bountycastle for encryption and since bountycastle latest version breaks iText support I had to use a lower version of this library in order for this to work [according to this thread](http://stackoverflow.com/questions/10391271/itext-bouncycastle-classnotfound-org-bouncycastle-asn1-derencodable-and-org-boun) – soaP Jul 16 '15 at 21:44

1 Answers1

1

Adding this maven dependency solved this issue for me

    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15</artifactId>
        <version>1.44</version>
    </dependency>
soaP
  • 101
  • 5