Fix #538: PDFValidation for PDF/A-3A always invalid

This fixes the bug where validation of actually valid PDF/A-3A files
always claimed that the PDF is "Not a PDF/A-3".
In fact, the validation was only accepting levels 3B and 3U.
This commit is contained in:
melo0187
2024-10-31 16:50:09 +01:00
parent 10a2a0e9e5
commit 9afe593562
3 changed files with 15 additions and 2 deletions

View File

@@ -52,7 +52,7 @@ public class PDFValidator extends Validator {
}
private static final Logger LOGGER = LoggerFactory.getLogger(PDFValidator.class.getCanonicalName()); // log output
private static final PDFAFlavour[] PDF_A_3_FLAVOURS = {PDFAFlavour.PDFA_3_A, PDFAFlavour.PDFA_3_A, PDFAFlavour.PDFA_3_A};
private static final PDFAFlavour[] PDF_A_3_FLAVOURS = {PDFAFlavour.PDFA_3_A, PDFAFlavour.PDFA_3_B, PDFAFlavour.PDFA_3_U};
private String pdfFilename;
@@ -301,8 +301,10 @@ public class PDFValidator extends Validator {
if (!processorResult.getValidationResult().isCompliant()) {
context.setInvalid();
}
PDFAFlavour pdfaFlavourFromValidationResult = processorResult.getValidationResult().getPDFAFlavour();
if (Arrays.stream(PDF_A_3_FLAVOURS)
.anyMatch(pdfaFlavour -> processorResult.getValidationResult().getPDFAFlavour().equals(pdfaFlavour))) {
.noneMatch(pdfaFlavourFromValidationResult::equals)) {
context.addResultItem(
new ValidationResultItem(ESeverity.error, "Not a PDF/A-3").setSection(23).setPart(EPart.pdf));

View File

@@ -141,6 +141,17 @@ public class ZUGFeRDValidatorTest extends ResourceCase {
}
public void testPDFA3AValidation() {
File tempFile = getResourceAsFile("zugferd_2p1_EXTENDED_PDFA-3A.pdf");
ZUGFeRDValidator zfv = new ZUGFeRDValidator();
String res = zfv.validate(tempFile.getAbsolutePath());
assertThat(res).valueByXPath("/validation/pdf/summary/@status")
.isEqualTo("valid");
}
/***
* the XMLValidatorTests only cover the <xml></xml> part, this one includes the root element and
* the global <summary></summary> part as well