List of usage examples for org.apache.pdfbox.preflight Format PDF_A1B
Format PDF_A1B
To view the source code for org.apache.pdfbox.preflight Format PDF_A1B.
Click Source Link
From source file:at.gv.egiz.pdfas.lib.impl.signing.pdfbox2.PADESPDFBOXSigner.java
License:EUPL
private void runPDFAPreflight(final DataSource signedDocument) throws PdfAsException { PreflightDocument document = null;/* w w w .j a v a2s. c o m*/ ValidationResult result = null; try { PreflightParser parser = new PreflightParser(signedDocument); parser.parse(Format.PDF_A1B); parser.parse(); document = parser.getPreflightDocument(); document.validate(); document.close(); result = document.getResult(); if (result.getErrorsList().size() > 0) { logger.error("The following validation errors occured for PDF-A validation"); } for (ValidationResult.ValidationError ve : result.getErrorsList()) { logger.error("\t" + ve.getErrorCode() + ": " + ve.getDetails()); } if (!result.isValid()) { throw new PdfAsException("The file is not a valid PDF-A document"); } } catch (SyntaxValidationException e) { logger.error("The file is syntactically invalid.", e); throw new PdfAsException("Resulting PDF Document is syntactically invalid."); } catch (ValidationException e) { logger.error("The file is not a valid PDF-A document.", e); throw new PdfAsException("The file is not a valid PDF-A document"); } catch (IOException e) { logger.error("An IOException (" + e.getMessage() + ") occurred, while validating the PDF-A conformance", e); throw new PdfAsException("Failed validating PDF Document IOException."); } catch (RuntimeException e) { logger.debug( "An RuntimeException (" + e.getMessage() + ") occurred, while validating the PDF-A conformance", e); throw new PdfAsException("Failed validating PDF Document RuntimeException."); } finally { if (document != null) { IOUtils.closeQuietly((Closeable) document); } } }