Remove leading characters from extracted XMP metadata.

This commit is contained in:
langfr
2026-03-26 12:27:49 +01:00
parent 56b9099c3c
commit 0ba2bf5363
3 changed files with 10 additions and 1 deletions

View File

@@ -127,7 +127,7 @@ public class PDFValidator extends Validator {
final ZUGFeRDImporter zi = new ZUGFeRDImporter(); final ZUGFeRDImporter zi = new ZUGFeRDImporter();
zi.doIgnoreCalculationErrors();//of course the calculation will still be schematron checked zi.doIgnoreCalculationErrors();//of course the calculation will still be schematron checked
zi.setInputStream(inputStream); zi.setInputStream(inputStream);
final String xmp = zi.getXMP(); final String xmp = zi.getXMP().substring(zi.getXMP().indexOf('<'));
final Document docXMP; final Document docXMP;

View File

@@ -179,6 +179,15 @@ public class PDFValidatorTest extends ResourceCase {
assertEquals(true, actual assertEquals(true, actual
.contains("<error type=\"28\">XMP Metadata: Could not parse XMP metadata (XML invalid)</error>")); .contains("<error type=\"28\">XMP Metadata: Could not parse XMP metadata (XML invalid)</error>"));
contents = getResourceAsByteArray("103767-Invoice-2026-03-24-1.pdf");
pv.setFilenameAndContents("103767-Invoice-2026-03-24-1.pdf", contents);
vc.clear();
pv.validate();
actual = pv.getXMLResult();
assertEquals(false, actual.contains("<error"));
} catch (final IrrecoverableValidationError e) { } catch (final IrrecoverableValidationError e) {
// ignore, will be in XML output anyway // ignore, will be in XML output anyway
} }