使用iText阅读pdf [英] Read pdf using iText

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

问题描述

我在java中使用iText读取pdf文件时遇到问题。我只能阅读一页,但当我转到第二页时,它会给出异常。我想阅读任何pdf文件的所有页面。

I am getting problem to read pdf files using iText in java. I can read only one page but when I go to second page it gives exception.I want to read all the pages of any pdf file.

PdfTextExtractor parser =new PdfTextExtractor(new PdfReader("C:/Text.pdf"));
parser.getTextFromPage(3);

我使用这些行,在第二行给出例外。

I am using these lines and at second line gives exception.

推荐答案


  1. 尝试更改文件位置。有时OS不允许其他应用程序从某些系统驱动器读取文件。把它放在D:等等。我在Vista中从桌面读取文件时遇到了这个问题。

  1. Try changing the file location. Sometimes OS does not allow file to be read from some system drives by other applications. Put somewhere in D: etc. I face this problem in Vista when reading files from desktop.

我实际上在其中一个上运行了相同的两行代码我的PDF和它确实打印了文本。还要确保PDF中有足够的页面。 (3页或更多页)或尝试使用parser.getTextFromPage(1)等从其他页面获取内容。

I in fact ran the same two lines of code on one of my PDF and it did print the text. Also make sure you have sufficient pages in the PDF. (3 pages or more) or try with parser.getTextFromPage(1) etc. to get content from other pages.

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

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