use of org.apache.pdfbox.io.RandomAccessBufferedFileInputStream in project pdfbox by apache.
the class PDDocument method load.
/**
* Parses a PDF.
*
* @param file file to be loaded
* @param password password to be used for decryption
* @param keyStore key store to be used for decryption when using public key security
* @param alias alias to be used for decryption when using public key security
* @param memUsageSetting defines how memory is used for buffering PDF streams
*
* @return loaded document
*
* @throws IOException in case of a file reading or parsing error
*/
public static PDDocument load(File file, String password, InputStream keyStore, String alias, MemoryUsageSetting memUsageSetting) throws IOException {
RandomAccessBufferedFileInputStream raFile = new RandomAccessBufferedFileInputStream(file);
try {
ScratchFile scratchFile = new ScratchFile(memUsageSetting);
try {
PDFParser parser = new PDFParser(raFile, password, keyStore, alias, scratchFile);
parser.parse();
return parser.getPDDocument();
} catch (IOException ioe) {
IOUtils.closeQuietly(scratchFile);
throw ioe;
}
} catch (IOException ioe) {
IOUtils.closeQuietly(raFile);
throw ioe;
}
}
Aggregations