Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以使用 PDF Box 获取 PDF 文档页面的快照?我想使用关键字匹配 pdf 文件中的页面,然后显示找到该文本的页面的快照。任何人都可以指出我应该从哪里开始吗?我计划为此使用 Lucene 和 PDF 框,以及 C#。
是的,您可以使用 pdfbox 执行此操作。像这样的东西:
pdf = PDDocument.load(inputStream); // this gets you page 1 byte[] bytes = getImageBytes(pdf, 1); // write out bytes as an image file
您可以使用 PDFTextStripper.getText() 提取文本
等等但是我认为你会从 xpdf 中得到更好的结果——它更成熟并且支持更多的 pdf 品种。