不好用,转完问题挺多,百度还找不到资料头疼。
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. leetcode 签到 面试题40. 最小的k个数

    题目 输入整数数组 arr ,找出其中最小的 k 个数.例如,输入4.5.1.6.2.7.3.8这8个数字,则最小的4个数字是1.2.3.4. 示例 1: 输入:arr = [3,2,1], k = ...

  2. SpringBoot使用RedisTemplate操作Redis时,key值出现 \xac\xed\x00\x05t\x00\tb

    原因分析 原因与RedisTemplate源码中的默认序列化方式有关 defaultSerializer = new JdkSerializationRedisSerializer( classLoa ...

  3. Ubuntu复制粘贴快捷键

    复制:[Ctrl+Insert] 粘贴:[Shitf+Insert]

  4. turtle实例

    1.彩虹 (1) from turtle import * def HSB2RGB(hues): hues = hues * 3.59 #100转成359范围 rgb=[0.0,0.0,0.0] i ...

  5. Centos6升级内核方法

    docker需要内核在3.0以上,如果centos6上需要安装docker的话需要先将内核进行升级 工具/原料   Centos6.5_x64 方法/步骤     操作系统为centos6.5,内核为 ...

  6. PTA | 1014 福尔摩斯的约会 (20分)

    大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.大侦探很快就明白了,字条上奇 ...

  7. 数据库服务概述,构建MYSQL服务器,数据库基本管理,mysql数据类型,表结构的调整

                                                            数据库的发展前引 MySQL的起源与发展过程 最为著名.应用最广泛的开源数据库软件 最早 ...

  8. NAT及静态转换,动态转换及PAT

    NAT及静态转换,动态转换及PAT 案例1:配置静态NAT 案例2:配置端口映射 案例3:配置动态NAT 案例4:PAT配置 案例5:办公区Internet的访问 1 案例1:配置静态NAT 1.1 ...

  9. k8s集群搭建笔记(细节有解释哦)

    本文中所有带引号的命令,请手动输入引号,不知道为什么博客里输入引号,总是自动转换成了中文 基本组成 pod:k8s 最小单位,类似docker的容器(也许) 资源清单:资源.资源清单语法.pod生命周 ...

  10. MODIS系列之NDVI(MOD13Q1)三:.jdk文件配置+MRT安装

    MRT(MODIS Reprojection Tool)简介: MODIS的全称为中分辨率成像光谱仪(Moderate-Resolution Imaging Spectroradiometer),是搭 ...