不好用,转完问题挺多,百度还找不到资料头疼。
public static void docxToHtml(String fileUrl) throws Exception {
String path = fileUrl.substring(0,fileUrl.indexOf("."));
File file = new File(fileUrl);
WordprocessingMLPackage wordMLPackage = Docx4J.load(file);
HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
String imageFilePath = path+"/images/";
if(!new File(imageFilePath).exists())
new File(imageFilePath).mkdirs();
htmlSettings.setImageDirPath(imageFilePath);
htmlSettings.setImageTargetUri("images");
htmlSettings.setWmlPackage(wordMLPackage);
String userCSS = "html, body, div, span, h1, h2, h3, h4, h5, h6, p, a, img, ol, ul, li, table, caption, tbody, tfoot, thead, tr, th, td " +
"{ margin: 0; padding: 0; border: 0;}" +
"body {line-height: 1; padding: 30px;} ";
userCSS = "body {padding: 30px;}";
htmlSettings.setUserCSS(userCSS); //
OutputStream os = new FileOutputStream(path+"/"+file.getName().substring(0,file.getName().indexOf("."))+".html");
Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);
Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
} public static void main(String[] args) throws Exception {
WordToHtml.docxToHtml("E:\\desktop\\3.docx");
}

docx4j docx转html的更多相关文章

  1. java实现word生成并转pdf

    前言 本篇博客主要解决java后台动态生成word(docx格式),并将word转换为pdf并添加水印. 思考 项目需求是要导出带水印的pdf,表格样式还是有点复杂的,之前考虑过用itextpdf根据 ...

  2. 【docx4j】docx4j操作docx,实现替换内容、转换pdf、html等操作

    主要是想要用此功插件操作docx,主要的操作就是操作段落等信息,另外,也想实现替换docx的内容,实现根据模板动态生成内容的效果,也想用此插件实现docx转换pdf. word的格式其实可以用xml来 ...

  3. 使用docx4j编程式地创建复杂的Word(.docx)文档

    原文链接:Create complex Word (.docx) documents programatically with docx4j 原文作者:jos.dirksen 发表日期:2012年2月 ...

  4. 使用Docx4j创建word文档

    原文标题:Creating Word documents with Docx4j 原文链接:http://blog.iprofs.nl/2012/09/06/creating-word-documen ...

  5. 向Docx4j生成的word文档中添加布局--第二部分

    原文标题:Adding layout to your Docx4j-generated word documents, part 2 原文链接:http://blog.iprofs.nl/2012/1 ...

  6. 向Docx4j生成的word文档添加图片和布局--第一部分

    原文标题:Adding images and layout to your Docx4j-generated word documents, part 1 原文链接:http://blog.iprof ...

  7. docx4j基本操作

    最近需要用docx4j来对docx进行一些操作,用到的技术是docx4j,这个技术在国内其实用的不是很多,看了一些博主的文章,有些感悟,做了一些总结,如果有疑问或错误之处欢迎交流. 创建包: Word ...

  8. [转]docx4j实现动态表格(模板式)

    原文地址:https://chendd.cn/information/viewInformation/other/257.a 除了前篇文章中讲到的编程式创建表格外,基于模板实现的列表表格也是非常常用或 ...

  9. java合并多个word 2007 文档 基于docx4j

    参考文章:http://dh.swzhinan.com/post/185.html 引入的jar包 <dependency> <groupId>org.docx4j</g ...

随机推荐

  1. 从SqlSessionFactoryBean的引用浅谈spring两种bean模式

    mybatis是以一个 SqlSessionFactory 的实例为中心的.SqlSessionFactory可以通过SqlSessionFactoryBuilder获得实例.使用mybatis-sp ...

  2. JSOI 2016 病毒感染 辅助Dp问题

    原题链接:https://www.luogu.com.cn/problem/P5774 分析 直接看这道题,第一个困惑点,那个绝对值的比较是什么东西,根据数学知识,我们可以知道这个意思是k到i的距离小 ...

  3. 重磅!刷新两项世界纪录的腾讯优图人脸检测算法DSFD开源了!

    近日,知名开源社区Github上有个名为DSFD(Dual Shot Face Detector)的算法引起了业内关注,它正是来自于腾讯优图.目前,该算法已经被计算机视觉顶级会议CVPR 2019接收 ...

  4. 开发一个基础的npm包

    初始化项目 # 新建文件夹 mkdir whosmeya-npm-package-test # 进入 cd whosmeya-npm-package-test/ # 初始化 package.json, ...

  5. SpringBoot,SpringMvc, SpringCloud

    1,SpringBoot VS SpringMvc VS SpringBoot SpringBoot: SpringBoot 是一个快速开发的框架,能够快速的整合第三方框架,简化XML配置,全部采用注 ...

  6. c++中的多态机制

    目录 1  背景介绍 2  多态介绍 2-1  什么是多态 2-2  多态的分类 2-3  动态多态成立的条件 2-4  静态联编和动态联编 2-5  动态多态的实现原理    2-6   虚析构函数 ...

  7. [vijos1554&bzoj1411]硬币游戏<快速幂>

    题目链接:https://vijos.org/p/1554 http://www.lydsy.com/JudgeOnline/problem.php?id=1411 这题真的淫*QAQ... 一看题还 ...

  8. CtenOS开放3306端口

    1.查看防火墙状态 2. 关闭防火墙firewall 3. 开启端口 4. 重启防火墙 5. 常用命令介绍 在 Centos 7 中防火墙由 firewalld 来管理,而不是 iptables. 1 ...

  9. java中eclipse的安装和JDK的环境变量的配置以及记事本的使用

    2020-04-09 23:26:15 学习java的第一步当然就是环境配置了,java中的配置作为小白刚刚开始肯定会有点一点晕头转向的,开没等开始入门呢!就要准备放弃了.哈哈哈哈,没关系的,都是这么 ...

  10. Linux命令后面加 & 的作用

    在命令的后面加一个 & 的作用是,将这个任务放到后台执行.看下面的例子. 输入gedit回车,可以看到,打开了Linux的文本编辑器,但是命令窗口执行不了其他命令了,只有退出文本编辑器才能继续 ...