Does JaperReports support PDF/A compliant export?
Starting from JasperReports Library 126.96.36.199 we support PDF/A compliant export ( PDF/A-1a and PDF/A-1b variants only).
This means that JasperReports Server 4.2.1, iReport 4.2 and all the subsequent releases support PDF/A export.
You can check for more informaton on how to generate PDF/A1 compliant files in JasperReports library samples, /demo/samples/jasper.
In the jrxml, the images that contain transparent elements must be marked with a key (e.g. TransparentImage) like this:
<img scaleimage="Clip" /><reportelement height="40" key="TransparentImage" uuid="f61e2b11-b485-4ca0-bb45-d9e7eb58d323" width="165" x="0" y="5"> <imageexpression> <!--[CDATA["jasperreports.png"]]--> </imageexpression> <hyperlinktooltipexpression> <!--[CDATA["The JasperReports Logo"]]--> </hyperlinktooltipexpression></reportelement>[/code]
These images will be removed from export, with a config property, because they're not supported by this standard.
Finally, the config properties. Set them in the jrxml:
exclude transparent images; either leave the value blank or set it with the key:
<property name="net.sf.jasperreports.export.pdf.exclude.key.TransparentImage" value="" />[/code]
include structure tags for PDF/A-1a compliance; unnecessary for PDF/A-1b:
<property name="net.sf.jasperreports.export.pdf.tagged" value="true" />[/code]
set pdfa conformance - pdfa1a/pdfa1b/none:
<property name="net.sf.jasperreports.export.pdfa.conformance" value="pdfa1a" />[/code]
specify the path of the ICC profile:
<property name="net.sf.jasperreports.export.pdfa.icc.profile.path" value="/home/user/AdobeRGB1998.icc" />[/code]
Posted by The Dentist on March 24, 2014 - 7:14am
After having spend a lot of time on this matter, we have found out how to get PDF/A-1a working with our application. There are some things to do that are not mentioned in the howto that I had linked in my question:
- You'll need to embed your fonts in your pdf. In Jaspersoft Studio, make sure that the fonts are listed in the corresponding menu of your projects properties (don't confuse with your reports properties). From that menu, you should be able to export the fonts as jar, which you should include in your build path to embed the fonts within your java application. I also set the net.sf.jasperreports.default.pdf.embedded property to true, although that may not be necessary.
- Make sure you have a default style. To do so, open the styles section of your report and select the style you'd like to make default or open your style template if you use one and select the font there. Then, under advanced set default to true. If you had no style in your report so far, add one by right-clicking on the styles entry and find your way through the menus. You'll be able to refer to an existing style template as well.
Additional hint: when trying to set up a PDF/A-1a document for the first time, make sure you use an image format that does not know transpareny (like jpeg) and don't use "one empty record" as datasource, but set up some datasource yourself (seems like with "one empty record", Jaspersoft Studio will show a page on the preview, but won't eport to pdf anything). Maybe png without transparency will work, too (haven't tried yet), and the datasource is independant from pdf/a technically, these things may help limiting the sources of errors.
As of now, I was able to get it to work with my client application only. I had no luck to export pdf/a-1a from Jaspersoft Studio so far.