I am using JasperReports to generate PDF documents and attempting to validate them with the Mustang library via
ZUGFeRDValidator validator = new ZUGFeRDValidator();
return validator.validate("./mypdf.pdf");
However, I encounter the following error: "A CIDSet entry in the Font descriptor does not correctly identify all glyphs present in the embedded font subset."
I am using the following libraries:
- JasperReports Version: 6.21.3
- Mustang Validator Version: 2.11.0
- PDFBox Version: 3.0.2
Here is the code I use to create pdfs:
generate(JasperReport report, Map<String,Object> data) {
[...]
JasperPrint print = JasperFillManager.fillReport(report, data, new JREmptyDataSource());
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(new SimpleExporterInput(print));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(document));
SimplePdfExporterConfiguration exportConfig = new SimplePdfExporterConfiguration();
exportConfig.setPdfVersion(PdfVersionEnum.VERSION_1_7);
exportConfig.setPdfaConformance(PdfaConformanceEnum.PDFA_3B);
exportConfig.setIccProfilePath("AdobeRGB1998.icc");
exportConfig.setMetadataAuthor("Your Name");
exportConfig.setTagged(true);
exportConfig.setTagLanguage("en-us");
exportConfig.setEmbedIccProfile(true);
exporter.setConfiguration(exportConfig);
exporter.exportReport();
[...]
}
The fonts that I’m using are OpenSans fonts:
In my fontsfamily.xml:
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="OpenSans">
<!-- Normal Font -->
<normal><![CDATA[fonts/OpenSans-Regular.ttf]]></normal>
<!-- Bold Font -->
<bold><![CDATA[fonts/OpenSans-Bold.ttf]]></bold>
<!-- Italic Font -->
<italic><![CDATA[fonts/OpenSans-Italic.ttf]]></italic>
<!-- Bolt italic Font -->
<boldItalic><![CDATA[fonts/OpenSans-BoldItalic.ttf]]></boldItalic>
<!-- Is font is embedded in PDF -->
<pdfEmbedded><![CDATA[true]]></pdfEmbedded>
</fontFamily>
</fontFamilies>
In my jasperreports_extension.properties:
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.OpenSans=fonts/fontsfamily.xml
I suspected that there might be an issue with how I embed the font, so here are my attempts:
- I have ensured that the fonts are embedded as subsets by using the isPdfEmbedded attribute like this:
<style name="Standard" isDefault="true" pattern="" fontName="OpenSans" fontSize="10" isPdfEmbedded="true"/>
The pdf acrobat reader also shows in the font properties that a subset of the font is embedded.
-
The error also occurs when I comment out all text from the .jrxml report template, leaving only the font styles embedded.
-
I tried out another font as well (DejaVu Sans), to see if OpenSans is the problem but it didn’t work either.
I know that the error is related to a CIDSet, but it seems that it is implicit which I might have no control of?
What else can I do?