【问题标题】:Read pdf file line by line using java [duplicate]使用java逐行读取pdf文件[重复]
【发布时间】:2015-12-14 05:06:04
【问题描述】:

如何使用java逐行读取pdf文件,并将行写入.txt和.doc文件? 请提及该程序所需的 .jar。

【问题讨论】:

  • 这是你需要在搜索引擎中写的东西,而不是在这里。
  • 不!我没有找到答案作为我的要求。我在 C++ 中得到了答案。
  • 我也没有找到如何在 txt 文件中写入该行。我已经解决了问题,但是不能逐行读写数据

标签: java pdf doc


【解决方案1】:

使用PDFBox

try{
PDDocument document = null; 
document = PDDocument.load(new File("test.pdf"));
document.getClass();
if( !document.isEncrypted() ){
    PDFTextStripperByArea stripper = new PDFTextStripperByArea();
    stripper.setSortByPosition( true );
    PDFTextStripper Tstripper = new PDFTextStripper();
    String st = Tstripper.getText(document);
    System.out.println("Text:"+st);
}
}catch(Exception e){
    e.printStackTrace();
}

您可以从here下载它

【讨论】:

  • sn-p不会逐行处理PDF。
猜你喜欢
  • 2011-09-10
  • 1970-01-01
  • 2015-05-19
  • 2020-02-21
  • 2017-08-29
  • 1970-01-01
  • 2016-01-24
  • 2012-09-05
  • 1970-01-01
相关资源
最近更新 更多