【发布时间】:2020-10-14 23:13:45
【问题描述】:
目前我正在尝试使用 Eclipse 中的 PDFBox 通过文本阅读器在文件夹中运行多个 PDF 文件,该文本阅读器将提取某些术语并将它们输出到文本文件中,然后我将其转换为 Excel 工作表。目前我有这个程序,它适用于单个 PDF 文件:
public static void main(String args[]) throws IOException {
//Loading an existing document
File file = new File("ADE_acetylfuranoside_120319_pfister.pdf");
PDDocument document = PDDocument.load(file);
//Instantiate PDFTextStripper class
PDFTextStripper pdfStripper = new PDFTextStripper();
//Retrieving text from PDF document
String text = pdfStripper.getText(document);
//...“提取文本的实际代码”...
PrintStream o = new PrintStream(new File("output.txt"));
PrintStream console = System.out;
System.setOut(o);
System.out.println(finalSheet);
我的问题是我想在 Eclipse 上通过这个程序在一个文件夹中运行 500 个 PDF,而不是单独输入每个文件的名称。我也希望它输出如下:
姓名1、号码1、ID1 姓名2、号码2、ID2
但我认为如果我运行多个 PDF,它现在的编写方式只会覆盖第一行。
感谢您的帮助!
【问题讨论】: