赞
踩
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(); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。