PDFbox Preflight PDF/A-1b检查在Java版本1.8中无法正常工作
我正在使用PDFBOX Preflight来验证pdf文档,以检查它是否为PDF/A-1b格式.它在Java 1.7上完美运行,但是当我在Java 1.8中运行代码时,出现以下错误
I am using PDFBOX Preflight to validate pdf document to check whether it is in PDF/A-1b format or not . It works perfectly on java 1.7 but when I run the code in java 1.8 i get following errors
2.4.3:无效的色彩空间,缺少DestOutputProfile
2.4.3 : Invalid Color space, DestOutputProfile is missing
2.4.3:无效的色彩空间,缺少DestOutputProfile
2.4.3 : Invalid Color space, DestOutputProfile is missing
2.4.3:无效的色彩空间,缺少DestOutputProfile
2.4.3 : Invalid Color space, DestOutputProfile is missing
7.11:元数据错误
7.11 : Error on MetaData
我正在使用pdfbox 1.8.8和preflight 1.8.3
I am using pdfbox 1.8.8 and preflight 1.8.3
以下是我用来验证执行此操作的PDF的代码.
Following is the code that I am using for validating the PDFs doing this.
ValidationResult result = null;
FileDataSource fd = new FileDataSource(InputFolder
+ listOfFiles[i].getName());
PreflightParser parser = new PreflightParser(fd);
try {
parser.parse(Format.PDF_A1A);
PreflightDocument documentt = parser
.getPreflightDocument();
documentt.validate();
result = documentt.getResult();
documentt.close();
} catch (SyntaxValidationException e) {
result = e.getResult();
}
if (result.isValid()) {
System.out
.println("The file is a valid PDF/A-1a file");
} else {
System.out.println("The file is not valid, error(s) :");
for (ValidationError error : result
.getErrorsList()) {
message = error.getErrorCode() + " : "
+ error.getDetails();
fos.write(message.getBytes());
fos.write(System.getProperty(
"line.separator").getBytes());
// System.out.println(error.getErrorCode() +
// " : " + error.getDetails());
}
}
PDFBOX是否与Java 1.8不兼容,或者我做错了什么?
Is PDFBOX not compatible with java 1.8 or am I doing something wrong ?
在注释中已解决:始终使用相同版本的PDFBox和Preflight jar文件,在编写此响应时为1.8.8.
As solved in the comments: always use the same version of the PDFBox and the Preflight jar files, which is 1.8.8 at the time this response is written.
其他奖励建议:在获得您不相信的结果时,请通过免费的PDF工具PDF/A-1b验证器.
Additional bonus advice: when getting results that you don't believe, get a "2nd opinion" with the free PDF-Tools PDF/A-1b validator.
如果结果不同,请在 JIRA 中打开一个问题,或尝试使用 PDFBox +预检的2.0快照:
If the results are different, open an issue in JIRA or try the 2.0 snapshots of PDFBox + preflight: