Hello,
I have a requirement from users to encrypt the PDF files generated based on the result of one query.
The password should be set dynamically based on the value returned by a query.
Is it possible ? And if yes this would be good if example can be shared.
Thanks,
Frederic
1 Answer:
Posted on April 23, 2023 at 7:37pm
Frederic,
Maybe this is the best information for u: https://jasperreports.sourceforge.net/sample.reference/pdfencrypt/index....
example
JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outFile)); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setEncrypted(true); configuration.set128BitKey(true); configuration.setUserPassword("jasper"); configuration.setOwnerPassword("reports"); configuration.setPermissions(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING); exporter.setConfiguration(configuration);
hope to help u ,
whatClasss