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