本文整理了Java中org.apache.pdfbox.pdmodel.PDDocument.load()
方法的一些代码示例,展示了PDDocument.load()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PDDocument.load()
方法的具体详情如下:
包路径:org.apache.pdfbox.pdmodel.PDDocument
类名称:PDDocument
方法名:load
[英]Parses a PDF. Unrestricted main memory will be used for buffering PDF streams.
[中]解析PDF文件。不受限制的主内存将用于缓冲PDF流。
代码示例来源:origin: apache/pdfbox
@Override
PDDocument open() throws IOException
{
return PDDocument.load(file, password);
}
};
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF. Unrestricted main memory will be used for buffering PDF streams.
*
* @param input byte array that contains the document.
*
* @return loaded document
*
* @throws InvalidPasswordException If the PDF required a non-empty password.
* @throws IOException In case of a reading or parsing error.
*/
public static PDDocument load(byte[] input) throws InvalidPasswordException, IOException
{
return load(input, "");
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF.
*
* @param file file to be loaded
* @param memUsageSetting defines how memory is used for buffering PDF streams
*
* @return loaded document
*
* @throws InvalidPasswordException If the file required a non-empty password.
* @throws IOException in case of a file reading or parsing error
*/
public static PDDocument load(File file, MemoryUsageSetting memUsageSetting)
throws InvalidPasswordException, IOException
{
return load(file, "", null, null, memUsageSetting);
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF. Unrestricted main memory will be used for buffering PDF streams.
*
* @param input byte array that contains the document.
* @param password password to be used for decryption
*
* @return loaded document
*
* @throws InvalidPasswordException If the password is incorrect.
* @throws IOException In case of a reading or parsing error.
*/
public static PDDocument load(byte[] input, String password)
throws InvalidPasswordException, IOException
{
return load(input, password, null, null);
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF.
*
* @param file file to be loaded
* @param password password to be used for decryption
* @param memUsageSetting defines how memory is used for buffering PDF streams
*
* @return loaded document
*
* @throws InvalidPasswordException If the password is incorrect.
* @throws IOException in case of a file reading or parsing error
*/
public static PDDocument load(File file, String password, MemoryUsageSetting memUsageSetting)
throws InvalidPasswordException, IOException
{
return load(file, password, null, null, memUsageSetting);
}
代码示例来源:origin: apache/pdfbox
private PDDocument loadPDF(String pdfName) throws IOException
{
return PDDocument.load(new File(pdfName));
}
代码示例来源:origin: apache/pdfbox
@Override
PDDocument open() throws IOException
{
return PDDocument.load(new URL(urlString).openStream(), password);
}
};
代码示例来源:origin: apache/pdfbox
private void calculatePageSizeFromFile(String filename, int page) throws IOException
{
try (PDDocument document = PDDocument.load(new File(filename)))
{
// calculate height and width of document page
calculatePageSize(document, page);
}
}
代码示例来源:origin: apache/pdfbox
private void calculatePageSizeFromStream(InputStream documentStream, int page) throws IOException
{
try (PDDocument document = PDDocument.load(documentStream))
{
// calculate height and width of document page
calculatePageSize(document, page);
}
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF. Unrestricted main memory will be used for buffering PDF streams.
*
* @param file file to be loaded
*
* @return loaded document
*
* @throws InvalidPasswordException If the file required a non-empty password.
* @throws IOException in case of a file reading or parsing error
*/
public static PDDocument load(File file) throws InvalidPasswordException, IOException
{
return load(file, "", MemoryUsageSetting.setupMainMemoryOnly());
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF. The given input stream is copied to the memory to enable random access to the pdf.
* Unrestricted main memory will be used for buffering PDF streams.
*
* @param input stream that contains the document.
*
* @return loaded document
*
* @throws InvalidPasswordException If the PDF required a non-empty password.
* @throws IOException In case of a reading or parsing error.
*/
public static PDDocument load(InputStream input) throws InvalidPasswordException, IOException
{
return load(input, "", null, null, MemoryUsageSetting.setupMainMemoryOnly());
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF. Unrestricted main memory will be used for buffering PDF streams.
*
* @param file file to be loaded
* @param password password to be used for decryption
*
* @return loaded document
*
* @throws InvalidPasswordException If the password is incorrect.
* @throws IOException in case of a file reading or parsing error
*/
public static PDDocument load(File file, String password)
throws InvalidPasswordException, IOException
{
return load(file, password, null, null, MemoryUsageSetting.setupMainMemoryOnly());
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF. The given input stream is copied to the memory to enable random access to the pdf.
* Unrestricted main memory will be used for buffering PDF streams.
*
* @param input stream that contains the document.
* @param password password to be used for decryption
*
* @return loaded document
*
* @throws InvalidPasswordException If the password is incorrect.
* @throws IOException In case of a reading or parsing error.
*/
public static PDDocument load(InputStream input, String password)
throws InvalidPasswordException, IOException
{
return load(input, password, null, null, MemoryUsageSetting.setupMainMemoryOnly());
}
代码示例来源:origin: apache/pdfbox
/**
* Parses a PDF. Unrestricted main memory will be used for buffering PDF streams.
*
* @param input byte array that contains the document.
* @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
*
* @return loaded document
*
* @throws InvalidPasswordException If the password is incorrect.
* @throws IOException In case of a reading or parsing error.
*/
public static PDDocument load(byte[] input, String password, InputStream keyStore,
String alias) throws IOException
{
return load(input, password, keyStore, alias, MemoryUsageSetting.setupMainMemoryOnly());
}
代码示例来源:origin: apache/pdfbox
public static void main(String[] args) throws IOException
{
File file = new File("src/main/resources/org/apache/pdfbox/examples/rendering/",
"custom-render-demo.pdf");
try (PDDocument doc = PDDocument.load(file))
{
PDFRenderer renderer = new MyPDFRenderer(doc);
BufferedImage image = renderer.renderImage(0);
ImageIO.write(image, "PNG", new File("custom-render.png"));
}
}
代码示例来源:origin: apache/pdfbox
public static void main(String[] args) throws IOException
{
File file = new File("src/main/resources/org/apache/pdfbox/examples/rendering/",
"custom-render-demo.pdf");
try (PDDocument doc = PDDocument.load(file))
{
PDPage page = doc.getPage(0);
CustomGraphicsStreamEngine engine = new CustomGraphicsStreamEngine(page);
engine.run();
}
}
代码示例来源:origin: apache/pdfbox
private void extract(String pdfFile, String password) throws IOException
{
try (PDDocument document = PDDocument.load(new File(pdfFile), password))
{
AccessPermission ap = document.getCurrentAccessPermission();
if (!ap.canExtractContent())
{
throw new IOException("You do not have permission to extract images");
}
for (PDPage page : document.getPages())
{
ImageGraphicsEngine extractor = new ImageGraphicsEngine(page);
extractor.run();
}
}
}
代码示例来源:origin: apache/pdfbox
private void importXFDF( String[] args ) throws IOException
{
if( args.length != 3 )
{
usage();
}
else
{
ImportFDF importer = new ImportFDF();
try (PDDocument pdf = PDDocument.load( new File(args[0]) );
FDFDocument fdf = FDFDocument.loadXFDF( args[1] ))
{
importer.importFDF( pdf, fdf );
pdf.save( args[2] );
}
}
}
代码示例来源:origin: apache/pdfbox
private void importFDF( String[] args ) throws IOException
{
if( args.length != 3 )
{
usage();
}
else
{
ImportFDF importer = new ImportFDF();
try (PDDocument pdf = PDDocument.load( new File(args[0]) );
FDFDocument fdf = FDFDocument.load( args[1] ))
{
importer.importFDF( pdf, fdf );
pdf.save( args[2] );
}
}
}
代码示例来源:origin: spring-projects/spring-restdocs
private List<String> extractStrings(File pdfFile) throws IOException {
PDDocument pdf = PDDocument.load(pdfFile);
assertThat(pdf.getNumberOfPages()).isEqualTo(1);
StringExtractor stringExtractor = new StringExtractor();
stringExtractor.processPage(pdf.getPage(0));
return stringExtractor.getStrings();
}
内容来源于网络,如有侵权,请联系作者删除!