0

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.

R.S.
  • 367
  • 2
  • 14
  • 1
    Possible duplicate of [How can I export report to PDF/A-1a, PDF/A-1b?](https://stackoverflow.com/questions/36306170/how-can-i-export-report-to-pdf-a-1a-pdf-a-1b) – Petter Friberg Sep 25 '19 at 19:54
  • I'va already followed that answer, but i couldn't make it work with those instructions, that's why i submitted a new question – R.S. Sep 26 '19 at 08:48
  • Check the dupe you need to specify full name of .içc file, in that example (with just filename, it's in project root) – Petter Friberg Sep 26 '19 at 11:23

0 Answers0