Search in sources :

Example 1 with Format

use of org.apache.pdfbox.preflight.Format in project pdfbox by apache.

the class PreflightParser method parse.

/**
 * Parse the given file and check if it is a confirming file according to the given format.
 *
 * @param format
 *            format that the document should follow (default {@link Format#PDF_A1B})
 * @param config
 *            Configuration bean that will be used by the PreflightDocument. If null the format is used to determine
 *            the default configuration.
 * @throws IOException
 */
public void parse(Format format, PreflightConfiguration config) throws IOException {
    checkPdfHeader();
    try {
        super.parse();
    } catch (IOException e) {
        addValidationError(new ValidationError(PreflightConstants.ERROR_SYNTAX_COMMON, e.getMessage()));
        throw new SyntaxValidationException(e, this.validationResult);
    } finally {
        // TODO move file handling outside of the parser
        IOUtils.closeQuietly(source);
    }
    Format formatToUse = (format == null ? Format.PDF_A1B : format);
    createPdfADocument(formatToUse, config);
    createContext();
}
Also used : Format(org.apache.pdfbox.preflight.Format) SyntaxValidationException(org.apache.pdfbox.preflight.exception.SyntaxValidationException) IOException(java.io.IOException) ValidationError(org.apache.pdfbox.preflight.ValidationResult.ValidationError)

Aggregations

IOException (java.io.IOException)1 Format (org.apache.pdfbox.preflight.Format)1 ValidationError (org.apache.pdfbox.preflight.ValidationResult.ValidationError)1 SyntaxValidationException (org.apache.pdfbox.preflight.exception.SyntaxValidationException)1