Мы работаем над реализацией электронного ввода в Германии, используя Zugferd и PDF/A. При проверке нашего очень простого PDF с помощью ustag Validator (https://www.mustangproject.org/commandline/) мы в конечном итоге получаем это сообщение об ошибке:
ValidationResult [flavour=3u, totalAssertions=695, assertions=[TestAssertion [ruleId=RuleId [specification=ISO 19005-3:2012, clause=6.2.2, testNumber=2], status=failed, message=A content stream that references other objects, such as images and fonts that are necessary to fully render or process the stream, shall have an explicitly associated Resources dictionary as described in ISO 32000-1:2008, 7.8.3, location=Location [level=CosDocument, context=root/document[0]/pages[0](9 0 obj PDPage)/contentStream[0](14 0 obj PDContentStream)/operators[0]/xObject[0]/contentStream[0](17 0 obj PDContentStream)], locationContext=null, errorMessage=A content stream refers to resource(s) F1 not defined in an explicitly associated Resources dictionary]], isCompliant=false]
unknown
652
2
urn:cen.eu:en16931:2017
177
0
1270
< /code>
Однако, если бы мы удалили заголовок из нашего PDF, где он написал «Blatt: 1 von 1», ошибка валидатора исчезает. Поэтому это должно быть связано с тем, как заголовок ссылается на шрифты, верно? По крайней мере, я думаю, что это так. Отсюда: https://drive.google.com/file/d/1oeloxz ... sp=sharing
Наш цель PDF, включая Zugferd XML, можно загрузить здесь: https: https: https. //drive.google.com/file/d/1j-tyikhbrffzxrod6wk908azo8jon3k4/view?usp=sharingобразно В качестве изображений и шрифтов, которые необходимы для полного отображения или обработки потока, должны иметь явно связанный Словарь ресурсов, как описано в ISO 32000-1: 2008 ?
Spec (Spec (Spec https://pdfa.org/wp-content/uploads/201 ... te0010.pdf Page 8) здесь не очень полезна. Файл с использованием pdfbox для создания «допустимого» файла Zugferd. P> Однако при запуске валидатора Mustang с помощью этой команды < /p>
$ java -jar Mustang-CLI-2.16.2.jar --action validate --no-notice --source Beleg_245210299_20241201_out.pdf
Мы в конечном итоге получаем сообщение об ошибке. UTF-8 байтов XML для прикрепления: < /p>
private void attachFile(String filename, String relationship, String description, String subType, byte[] data) throws IOException {
this.fileAttached = true;
PDComplexFileSpecification fs = new PDComplexFileSpecification();
fs.setFile(filename);
COSDictionary dict = fs.getCOSObject();
dict.setName("AFRelationship", relationship);
dict.setString("UF", filename);
dict.setString("Desc", description);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
PDEmbeddedFile ef = new PDEmbeddedFile(pdf, bais);
ef.setSubtype(subType);
ef.setSize(data.length);
ef.setCreationDate(Calendar.getInstance());
ef.setModDate(Calendar.getInstance());
fs.setEmbeddedFile(ef);
dict = fs.getCOSObject();
COSDictionary efDict = (COSDictionary) dict.getDictionaryObject(COSName.EF);
COSBase lowerLevelFile = efDict.getItem(COSName.F);
efDict.setItem(COSName.UF, lowerLevelFile);
PDDocumentNameDictionary names = new PDDocumentNameDictionary(pdf.getDocumentCatalog());
PDEmbeddedFilesNameTreeNode efTree = names.getEmbeddedFiles();
if (efTree == null) {
efTree = new PDEmbeddedFilesNameTreeNode();
}
Map namesMap = new HashMap();
Map oldNamesMap = efTree.getNames();
if (oldNamesMap != null) {
namesMap.putAll(oldNamesMap);
}
namesMap.put(filename, fs);
efTree.setNames(namesMap);
names.setEmbeddedFiles(efTree);
pdf.getDocumentCatalog().setNames(names);
COSBase afEntry = pdf.getDocumentCatalog().getCOSObject().getItem("AF");
COSArray cosArray;
if (afEntry == null) {
cosArray = new COSArray();
cosArray.add(fs);
pdf.getDocumentCatalog().getCOSObject().setItem("AF", cosArray);
} else if (afEntry instanceof COSArray) {
cosArray = (COSArray) afEntry;
cosArray.add(fs);
pdf.getDocumentCatalog().getCOSObject().setItem("AF", cosArray);
} else {
if (!(afEntry instanceof COSObject) || !(((COSObject) afEntry).getObject() instanceof COSArray)) {
throw new IOException("Unexpected object type for PDFDocument/Catalog/COSDictionary/Item(AF)");
}
cosArray = (COSArray) ((COSObject) afEntry).getObject();
cosArray.add(fs);
}
}
< /code>
Мы называем метод выше, как это: < /p>
this.attachFile(filename, "Alternative",
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.ph ... 231&lang=4)",
"text/xml", this.xmlProvider.getData());
Подробнее здесь: https://stackoverflow.com/questions/794 ... ence-error