PDFbox Preflight PDF/A-1b check not working properly in java version 1.8

半腔热情 提交于 2019-12-11 03:56:37

问题


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 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, DestOutputProfile is missing

7.11 : Error on MetaData

I am using pdfbox 1.8.8 and preflight 1.8.3

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());
                            }

}

Is PDFBOX not compatible with java 1.8 or am I doing something wrong ?


回答1:


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.

Additional bonus advice: when getting results that you don't believe, get a "2nd opinion" with the free PDF-Tools PDF/A-1b validator.

If the results are different, open an issue in JIRA or try the 2.0 snapshots of PDFBox + preflight:



来源:https://stackoverflow.com/questions/28112318/pdfbox-preflight-pdf-a-1b-check-not-working-properly-in-java-version-1-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!