i've been trying to tweak my PDFexport method, i'm trying to produce a PDF/A instead. I've followed some answers here on SO, but i haven't been able to make it work. Here's my previous code(exports standard pdf):
protected byte[] getPdfExport(List<JasperPrint> jasperPrint) {
byte[] ret = null;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setPermissions(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING);
JRPdfExporter exporterPDF = new JRPdfExporter();
try {
exporterPDF.setExporterInput(SimpleExporterInput.getInstance(jasperPrint));
exporterPDF.setExporterOutput(new SimpleOutputStreamExporterOutput(outStream));
exporterPDF.setConfiguration(configuration);
exporterPDF.exportReport();
// chiusura dei bytes
outStream.flush();
ret = outStream.toByteArray();
outStream.close();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
return ret;
}
These are the changes i've made following other answers here on this website:
protected byte[] getPdfExport(List<JasperPrint> jasperPrint) {
byte[] ret = null;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setPermissions(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING);
configuration.setPdfaConformance(PdfaConformanceEnum.PDFA_1A);
configuration.setIccProfilePath("C://Users//MyUser//Download//");
JRPdfExporter exporterPDF = new JRPdfExporter();
try {
exporterPDF.setExporterInput(SimpleExporterInput.getInstance(jasperPrint));
exporterPDF.setExporterOutput(new SimpleOutputStreamExporterOutput(outStream));
exporterPDF.setConfiguration(configuration);
exporterPDF.exportReport();
// chiusura dei bytes
outStream.flush();
ret = outStream.toByteArray();
outStream.close();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
In my local path, i have an .icc file. However, it doesn't work, i get the following expection:
net.sf.jasperreports.engine.JRException: Input stream not found at : myPath
What am i missing? Is it because i should add the .icc file inside the project, and thus not locally? Or am i missing something in my code? Thank you.