1

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

有什么工具可以从pdf中检索数据吗?提前致谢

4

3 回答 3

2

您可以使用Apache 的 PDFBox,老实说,我从未使用过它,但在论坛上阅读了很多有关它的信息。

其他选择可以是iTextJPedal

如果您有兴趣,可以尝试一下,但我相信使用 PDFBox,您将能够满足您的要求。

谢谢

于 2013-07-31T07:21:04.767 回答
0

考虑Apache PDFBox

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

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

于 2013-07-31T07:20:16.777 回答
0

使用PDFBOX

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));
    } 
}

在这里,我尝试了提取该部分。这可能会对您有所帮助。

于 2013-07-31T09:49:36.153 回答