Skip to content

Commit

Permalink
Upgrade preflight version
Browse files Browse the repository at this point in the history
  • Loading branch information
nntthuy-axonivy committed Feb 10, 2025
1 parent c720229 commit 38ebb68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc-factory-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<project.build.plugin.version>12.0.0</project.build.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tester.version>12.0.1</tester.version>
<pdfbox.version>2.0.28</pdfbox.version>
<pdfbox.version>3.0.4</pdfbox.version>
<powermock2.version>2.0.9</powermock2.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
package ch.ivyteam.ivy.addons.docfactory.pdfbox;

import java.io.File;
import java.io.IOException;

import org.apache.pdfbox.preflight.PreflightDocument;
import org.apache.pdfbox.preflight.ValidationResult;
import org.apache.pdfbox.preflight.parser.PreflightParser;

public class PdfAValidator {

/**
* This method checks the validity of the PDF/A files.
* https://pdfbox.apache.org/1.8/cookbook/pdfavalidation.html
* @param pdf the file to validate
* @return true if pdf box can validate the given file. Else false.
* @return true if PDF box can validate the given file. Else false.
* @throws IOException
*/
public static boolean isPDFACompliant(java.io.File pdf) throws IOException {
boolean isValid = false;
PreflightDocument document = null;
try {
PreflightParser parser = new PreflightParser(pdf);
parser.parse();
document = parser.getPreflightDocument();
document.validate();
isValid = document.getResult().isValid();
} catch (IOException e) {

} finally {
if (document != null) {
document.close();
}
}
return isValid;
public static boolean isPDFACompliant(File pdf) throws IOException {
ValidationResult validationResult = PreflightParser.validate(pdf);
return validationResult.isValid();
}

}
}

0 comments on commit 38ebb68

Please sign in to comment.