通过java阅读pdf [英] reading pdf through java

查看:77
本文介绍了通过java阅读pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i am reading pdf through java but problem is like that i am reading 500 pages at that time they can read only 496 pages plz tell me what can i do
my code is bellow










public class pdf1 {

	
	public static void main(String[] args) throws SQLException, ClassNotFoundException {
		try {

			PdfReader reader = new PdfReader("me1.pdf");
			
//			int n = reader.getNumberOfPages();
			 File outFile = new File("b.csv");
			int n=500;
			int count=0;
			 BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
			
			 for(int i=1;i<=n;i++)
			 {
			 String str=PdfTextExtractor.getTextFromPage(reader, i);
			 System.out.println(str);
			 writer.write(str);
			 count++;
			 }
			 System.out.println(count);

	} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

推荐答案

你应该使用 getNumberOfPages [ ^ ]检查文档的实际页数。
You should use getNumberOfPages[^] to check the actual page count of the document.


这篇关于通过java阅读pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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