В Java, как я могу экспортировать PDF / A, используя библиотеки отчетов Jasper? - PullRequest
0 голосов
/ 25 сентября 2019

Я пытался настроить метод PDFexport, вместо этого я пытаюсь создать PDF / A.Я следовал за некоторыми ответами здесь на SO, но я не смог заставить его работать.Вот мой предыдущий код (экспортирует стандартный 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;
}

Это изменения, которые я сделал, следуя другим ответам здесь на этом сайте:

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

На моем локальном пути яесть файл .icc.Однако, это не работает, я получаю следующее ожидание:

net.sf.jasperreports.engine.JRException: Input stream not found at : myPath

Что мне не хватает?Это потому, что я должен добавить .icc файл внутри проекта, и, следовательно, не локально?Или я что-то упустил в своем коде?Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...