确定PDF文件中的页数 [英] Determine the number of pages in a PDF file
本文介绍了确定PDF文件中的页数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用免费/开源Java API确定给定PDF文件中的页数?
How can I determine the number of pages in a given PDF file, using a free/open source Java API?
推荐答案
您可以使用 Apache PDFBox 加载PDF文档,然后调用 getNumberOfPages
方法返回页数。
You can use Apache PDFBox to load a PDF document and then call the getNumberOfPages
method to return the page count.
PDDocument doc = PDDocument.load(new File("file.pdf"));
int count = doc.getNumberOfPages();
这篇关于确定PDF文件中的页数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文