How can I export report to PDF/A-1a, PDF/A-1b?

后端 未结 1 639
春和景丽
春和景丽 2020-11-29 07:55

Generating PDF/A in jasper-report, contains numerous pitfalls and is not supported in some versions of jasper-report. This is why I have decided to pass this Q

1条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 08:29

    JasperReports Library 4.1.2.3 or higher is needed (with discontinued support in 6.0.0 see NullPointerException at the end).

    These steps are need to generate a PDF/A, they can be achieved both by java code or by setting jrxml property to root tag (jasper-server support). I will show both but only one method is necessary.

    #Set PDF/A Conformance

    java

    configuration.setPdfaConformance(PdfaConformanceEnum.PDFA_1A); // or PdfaConformanceEnum.PDFA_1B
    

    jrxml

    
    

    #Set ICC Profile

    to avoid JRPdfaIccProfileNotFoundException: The ICC profile is not available to the JVM

    java

    configuration.setIccProfilePath("srgb.icc");
    

    jrxml

    
    

    #Embed all font used in reports, using font-extensions

    If you still have error

    com.lowagie.text.pdf.PdfXConformanceException: All the fonts must be embedded. This one isn't: Helvetica
    

    include a default style in the jrxml indicating fontName that is included in font extension, example