【问题标题】:How to read PDF file through iText and display it as in Adobe Reader?如何通过 iText 阅读 PDF 文件并像在 Adob​​e Reader 中一样显示?
【发布时间】:2013-03-19 15:05:50
【问题描述】:

我使用com.itextpdf.text.pdf.PdfReadercom.itextpdf.text.pdf.parser.PdfTextExtractor 打包,并尝试:

String pagedata=PdfTextExtractor.getTextFromPage(reader,pageno)

并将页面数据放入 JTextArea。

但这样做会跳过所有图像、字体大小和颜色,只显示相同大小的文本数据。

我想像在 Adob​​e Reader 中那样逐页获取所有完整的数据。我该怎么做?我应该将获取的页面放在哪个组件中?显然不在 JTextArea 上...

【问题讨论】:

  • PdfTextExtractor.getTextFromPage 就像它的名字所说的那样,它从一页中提取文本,删除所有非文本和文本样式信息。 iText 目前不包含以图形方式呈现 PDF 的代码。
  • 那我该如何解决我的问题??
  • 例如 jPedal 是一个允许查看 PDF 的库。

标签: java swing pdf itext


【解决方案1】:

您可以使用 Desktop 类来调用 Adob​​e Reader。

Desktop.getDesktop().open(file.pdf);
// where file.pdf is your file instance.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-09
    • 2014-03-10
    • 1970-01-01
    • 2015-11-15
    • 1970-01-01
    • 2014-09-13
    相关资源
    最近更新 更多