当前位置:   article > 正文

org.apache.tika 解析word文档,跳过\删除页眉页脚_apache tika 提取pdf文本过滤掉页脚

apache tika 提取pdf文本过滤掉页脚

示例代码

public void parseExample() {

ParseContext parseContext = new ParseContext();
AutoDetectParser parser = new AutoDetectParser();
BodyContentHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();

//跳过页眉页脚
OfficeParserConfig officeParserConfig = new OfficeParserConfig();
officeParserConfig.setIncludeHeadersAndFooters(false);
boolean hf= officeParserConfig.getIncludeHeadersAndFooters();
parseContext.set(OfficeParserConfig.class, officeParserConfig);

System.out.println("headfoot"+hf);
try(FileInputStream fin=new FileInputStream("D:\\docs\\Out22.docx")) {
	parser.parse(fin, handler, metadata, parseContext);
	String text = handler.toString();
	System.out.println("output :"+text);
} catch (IOException | SAXException | TikaException ex) {
	ex.printStackTrace();
 }
}
       
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/665345
推荐阅读
相关标签
  

闽ICP备14008679号