Merge pull request #539 from melo0187/fix-pdfa-validation
Fix #538: PDFValidation for PDF/A-3A always invalid
This commit is contained in:
@@ -52,7 +52,7 @@ public class PDFValidator extends Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PDFValidator.class.getCanonicalName()); // log output
|
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;
|
private String pdfFilename;
|
||||||
|
|
||||||
@@ -301,8 +301,10 @@ public class PDFValidator extends Validator {
|
|||||||
if (!processorResult.getValidationResult().isCompliant()) {
|
if (!processorResult.getValidationResult().isCompliant()) {
|
||||||
context.setInvalid();
|
context.setInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PDFAFlavour pdfaFlavourFromValidationResult = processorResult.getValidationResult().getPDFAFlavour();
|
||||||
if (Arrays.stream(PDF_A_3_FLAVOURS)
|
if (Arrays.stream(PDF_A_3_FLAVOURS)
|
||||||
.anyMatch(pdfaFlavour -> processorResult.getValidationResult().getPDFAFlavour().equals(pdfaFlavour))) {
|
.noneMatch(pdfaFlavourFromValidationResult::equals)) {
|
||||||
context.addResultItem(
|
context.addResultItem(
|
||||||
new ValidationResultItem(ESeverity.error, "Not a PDF/A-3").setSection(23).setPart(EPart.pdf));
|
new ValidationResultItem(ESeverity.error, "Not a PDF/A-3").setSection(23).setPart(EPart.pdf));
|
||||||
|
|
||||||
|
|||||||
@@ -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 XMLValidatorTests only cover the <xml></xml> part, this one includes the root element and
|
||||||
* the global <summary></summary> part as well
|
* the global <summary></summary> part as well
|
||||||
|
|||||||
BIN
validator/src/test/resources/zugferd_2p1_EXTENDED_PDFA-3A.pdf
Normal file
BIN
validator/src/test/resources/zugferd_2p1_EXTENDED_PDFA-3A.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user