首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从pdf中检索特定部分的数据

从pdf中检索特定部分的数据
EN

Stack Overflow用户
提问于 2013-07-31 15:10:44
回答 3查看 1.9K关注 0票数 1

我需要从pdf文件中检索一些与关键字相关的数据。这些是关键词:标题,pdf的范围,谁提出的pdf,版本,摘要,状态,监管机构。

有没有工具可以从pdf中检索数据?提前感谢

EN

回答 3

Stack Overflow用户

发布于 2013-07-31 15:21:05

你可以使用PDFBox from Apache,老实说,我从来没有用过它,但在论坛上读了很多关于它的文章。

其他替代方案可以是iTextJPedal

如果你感兴趣,你可以试一试,但我相信使用PDFBox你将能够满足你的需求。

谢谢

票数 2
EN

Stack Overflow用户

发布于 2013-07-31 15:20:17

考虑Apache PDFBox

从PDF中提取文本,然后对其进行解析以获取所需信息。它是免费的。

此外,还有另一个工具iText,但如果您正在处理商业项目,则需要在iText上购买许可证。

票数 0
EN

Stack Overflow用户

发布于 2013-07-31 17:49:36

使用PDFBOX

代码语言:javascript
复制
public class PDFTextReader
{
   static String pdftoText(String fileName) {
        PDFParser parser;
        String parsedText = null;
        PDFTextStripper pdfStripper = null;
        PDDocument pdDoc = null;
        COSDocument cosDoc = null;
        File file = new File(fileName);
        if (!file.isFile()) {
            System.err.println("File " + fileName + " does not exist.");
            return null;
        }
        try {
            parser = new PDFParser(new FileInputStream(file));
        } catch (IOException e) {
            System.err.println("Unable to open PDF Parser. " + e.getMessage());
            return null;
        }
        try {
            parser.parse();
            cosDoc = parser.getDocument();
            pdfStripper = new PDFTextStripper();
            pdDoc = new PDDocument(cosDoc);
            // pdfStripper.setParagraphStart(FIND_START_VALUE);
            // pdfStripper.setParagraphEnd("FIND_END_VALUE);
            parsedText = pdfStripper.getText(pdDoc);
        } catch (Exception e) {
            System.err
                    .println("An exception occured in parsing the PDF Document."
                            + e.getMessage());
        } finally {
            try {
                if (cosDoc != null)
                    cosDoc.close();
                if (pdDoc != null)
                    pdDoc.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return parsedText;
    }
    public static void main(String args[]){

        System.out.println(pdftoText(FILEPATH));
    } 
}

在这里,我尝试了这个方法来提取部分。这可能会对你有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17963852

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档