关于poi解析word 转html 最后生成的html不能再生成时进行控制吗?

chenzhaoy 2018-02-07 05:18:50
public static void canExtractImage(String wordPath) throws IOException {
String name = StringUtils.substringBeforeLast(StringUtils.substringAfterLast(wordPath, "/"), ".");
File f = new File(wordPath);
Long randStr = System.currentTimeMillis(); //时间戳
// 1) Load DOCX into XWPFDocument
InputStream in = new FileInputStream(f);
XWPFDocument document = new XWPFDocument(in);

// 2) Prepare XHTML options (here we set the IURIResolver to
// load images from a "word/media" folder)
File imageFolderFile = new File("C:/Users/chency/Documents/"+name+randStr);
XHTMLOptions options = XHTMLOptions.create().URIResolver(
new FileURIResolver(imageFolderFile));
options.setExtractor(new FileImageExtractor(imageFolderFile));

// 3) Convert XWPFDocument to XHTML
OutputStream out = new FileOutputStream(new File(
"C:/Users/chency/Documents/"+name+randStr+".html"));
XHTMLConverter.getInstance().convert(document, out, options);
out.close();
}
...全文
920 回复 打赏 收藏 举报
写回复
回复
切换为时间正序
请发表友善的回复…
发表回复
相关推荐
发帖
Java

4.9w+

社区成员

Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
帖子事件
创建了帖子
2018-02-07 05:18
社区公告
暂无公告