使用 PDFBox 从 PDF 文档中读取特定页面 [英] Reading a particular page from a PDF document using PDFBox

查看:82
本文介绍了使用 PDFBox 从 PDF 文档中读取特定页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 PDFBox 从 PDF 文档中读取特定页面(给定页码)?

How do I read a particular page (given a page number) from a PDF document using PDFBox?

推荐答案

这应该有效:

PDPage firstPage = (PDPage)doc.getAllPages().get( 0 );

教程的书签部分

2015 年更新,2.0.0 版快照

似乎这已被删除并放回原处(?).getPage 在 2.0.0 javadoc.使用它:

Seems this was removed and put back (?). getPage is in the 2.0.0 javadoc. To use it:

PDDocument document = PDDocument.load(new File(filename));
PDPage doc = document.getPage(0);

getAllPages 方法已重命名 getPages

The getAllPages method has been renamed getPages

PDPage page = (PDPage)doc.getPages().get( 0 );

这篇关于使用 PDFBox 从 PDF 文档中读取特定页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆