Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ZUGFeRD/mustangproject
Browse files Browse the repository at this point in the history
  • Loading branch information
jstaerk committed Nov 5, 2024
2 parents 33ef461 + e8a1997 commit d8ba834
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public PDFValidator(ValidationContext ctx) {
}

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;

Expand Down Expand Up @@ -301,8 +301,10 @@ public void validate() throws IrrecoverableValidationError {
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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ public void testPDFValidationInputStream() {

}

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
Expand Down
Binary file not shown.

0 comments on commit d8ba834

Please sign in to comment.