1

I am trying to export a PDF file as PDFA/a1 with JasperReports, but it doesn't work and I really don't know why.

I want all the fonts to be embedded, but for some reason Helvetica isn't. How should I add the font to my project?

If you have ever exported a file as PDFA/a1 successfully, please tell me how I can I fix the issue, or give me just a sample that works and I'll find my issue from there.

Here is my the code I have so far:

byte[] byte_array=null;
    try {

        String directorio = BuscarCarpetaArchivosReport(context);

        File f = new File(directorio, report + ".jrxml");
        if (f.exists() && f.isFile()) {
            FileInputStream fis = new FileInputStream(f);
            //Compilo el JRXML
            JasperReport jasperReport = JasperCompileManager.compileReport(fis);


            Map parametrosAux=(Map)parametros.get("parametros");

            JasperPrint jasperPrint;

              jasperPrint = JasperFillManager.fillReport(jasperReport, parametrosAux, new JREmptyDataSource());

            JRPdfExporter Exporter= new JRPdfExporter();

            SimplePdfExporterConfiguration configuracio=new     SimplePdfExporterConfiguration();
            configuracio.setPdfaConformance(PdfaConformanceEnum.PDFA_1A);
            configuracio.setIccProfilePath(directorio+"sRGB_v4_ICC_preference.icc");
               configuracio.setPdfVersion(PdfVersionEnum.VERSION_1_6);

            List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>();
             jasperPrintList.add(jasperPrint);
            Exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
            java.io.ByteArrayOutputStream outputStream=new java.io.ByteArrayOutputStream();
            Exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputStream) );
            Exporter.setConfiguration(configuracio);
            Exporter.exportReport();
            byte_array=outputStream.toByteArray();


        } else {

        }
    } catch (Exception excep) {

              Logger.getLogger(BusquedaDatos.class.getName()).log(Level.SEVERE, null, excep);

    }
    return byte_array;
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Elmohmoh
  • 75
  • 2
  • 8
  • http://jasperreports.sourceforge.net/sample.reference/fonts/#fontextensions –  Dec 26 '15 at 01:31
  • Helvetica isn't because that is one of the standard 14 fonts which pdf viewers are expected to support out-of-the-box, so pdf generators support Helvetica but don't have a copy of the font to embed, merely of its metrics. Thus, use a different font you provide the font file for. For that you'll need the font extensions @Petter mentioned. – mkl Mar 27 '16 at 14:01

0 Answers0