Код: Выделить всё
ZUGFeRDValidator validator = new ZUGFeRDValidator();
return validator.validate("./mypdf.pdf");
- Версия JasperReports: 6.21.3
- Mustang Validator Версия: 2.11.0
- Версия PDFBox: 3.0.2
Код: Выделить всё
generate(JasperReport report, Map data, OutputStream document) {
[...]
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();
[...]
}
В моем Fontsfamily.xml:
Код: Выделить всё
Код: Выделить всё
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.OpenSans=fonts/fontsfamily.xml
- Я гарантировал, что шрифты будут встроены как подмножества, используя атрибут isPdfEmbedded следующим образом:
Код: Выделить всё
- Ошибка также возникает, когда я закомментирую весь текст из шаблона отчета .jrxml, оставив внедренными только стили шрифта.
- Я попробовал также другой шрифт (DejaVu Sans), чтобы проверить, не является ли проблема OpenSans, но он тоже не сработал.
РЕДАКТИРОВАТЬ
Я полностью упустил из виду тот факт, что есть больше, чем эта ошибка. Проверка также показывает, что метаданные xmp недействительны:
Код: Выделить всё
XMP Metadata: ConformanceLevel not found
XMP Metadata: ConformanceLevel contains invalid value
XMP Metadata: DocumentType not found
XMP Metadata: DocumentType invalid
XMP Metadata: DocumentFileName not found
XMP Metadata: DocumentFileName contains invalid value
XMP Metadata: Version not found
XMP Metadata: Version contains invalid value
Вот пример вывода.pdf для проверки с помощью mustang. Это пустая страница без текста, но все равно выдает ошибку. Я свел пример только к импорту шрифта через тег и не более того.
РЕДАКТИРОВАТЬ 2
Мне удалось удалить CIDSet, и проверка показала, что PDF-файл соответствует требованиям. Вот код:
Код: Выделить всё
for (PDPage page : document.getPages()) {
for (COSName fontName : page.getResources().getFontNames()) {
PDFont font = page.getResources().getFont(fontName);
if (font instanceof PDType0Font) {
PDType0Font type0Font = (PDType0Font) font;
PDCIDFont descendantFont = (PDCIDFont) type0Font.getDescendantFont();
if (type0Font.getDescendantFont() instanceof PDCIDFontType2) {
PDCIDFontType2 f = (PDCIDFontType2) type0Font.getDescendantFont();
PDFontDescriptor fontDescriptor = f.getFontDescriptor();
if (fontDescriptor instanceof PDFontDescriptor) {
PDFontDescriptor fontDict = (PDFontDescriptor) fontDescriptor;
fontDict.setCIDSet(null);
}
}
}
}
}
Я оставлю этот пост открыт, возможно, в будущем мы найдем более простое решение.
Подробнее здесь: https://stackoverflow.com/questions/787 ... iptor-does