soaP
soaP

Reputation: 101

Encryption of pdfs xDocReport (iText) using IPdfWriterConfiguration does not work

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();
}

Upvotes: 0

Views: 765

Answers (1)

soaP
soaP

Reputation: 101

Adding this maven dependency solved this issue for me

    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15</artifactId>
        <version>1.44</version>
    </dependency>

Upvotes: 1

Related Questions