Nic*_*zyk 26
这应该工作:
PDPage firstPage = (PDPage)doc.getAllPages().get( 0 );
Run Code Online (Sandbox Code Playgroud)
更新2015,版本2.0.0 SNAPSHOT
似乎已被删除并放回(?).getPage在2.0.0 javadoc中.要使用它:
PDDocument document = PDDocument.load(new File(filename));
PDPage doc = document.getPage(0);
Run Code Online (Sandbox Code Playgroud)
该getAllPages方法已更名GETPAGES
PDPage page = (PDPage)doc.getPages().get( 0 );
Run Code Online (Sandbox Code Playgroud)
Ray*_*ink 18
//Using PDFBox library available from http://pdfbox.apache.org/
//Writes pdf document of specific pages as a new pdf file
//Reads in pdf document
PDDocument pdDoc = PDDocument.load(file);
//Creates a new pdf document
PDDocument document = null;
//Adds specific page "i" where "i" is the page number and then saves the new pdf document
try {
document = new PDDocument();
document.addPage((PDPage) pdDoc.getDocumentCatalog().getAllPages().get(i));
document.save("file path"+"new document title"+".pdf");
document.close();
}catch(Exception e){}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
50455 次 |
| 最近记录: |