word转换成html及图片

word转换成html及图片
word转换成html及图片

package com.certusnet.portlet.freeterms.utils;

import java.awt.Image;

import java.awt.Rectangle;

import java.awt.image.BufferedImage;

import java.io.ByteArrayOutputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStreamWriter;

import java.io.RandomAccessFile;

import https://www.360docs.net/doc/7a3205385.html,.ConnectException;

import java.nio.ByteBuffer;

import java.nio.channels.FileChannel;

import java.util.Date;

import java.util.List;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

import javax.imageio.ImageIO;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.parsers.ParserConfigurationException;

import javax.xml.transform.OutputKeys;

import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerException;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.dom.DOMSource;

import javax.xml.transform.stream.StreamResult;

import org.apache.poi.hwpf.HWPFDocument;

import org.apache.poi.hwpf.converter.PicturesManager;

import org.apache.poi.hwpf.converter.WordToHtmlConverter;

import https://www.360docs.net/doc/7a3205385.html,ermodel.Picture;

import https://www.360docs.net/doc/7a3205385.html,ermodel.PictureType;

import org.w3c.dom.Document;

import com.artofsolving.jodconverter.DocumentConverter;

import

com.artofsolving.jodconverter.openoffice.connection.OpenOfficeCon nection;

import

com.artofsolving.jodconverter.openoffice.connection.SocketOpenOff iceConnection;

import

com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocu mentConverter;

import com.certusnet.portal.kernel.configuration.Configuration; import com.certusnet.portal.kernel.exception.PortalException; import com.certusnet.portal.kernel.util.PropsKeys;

import com.certusnet.portal.kernel.util.StringPool;

import

com.certusnet.portlet.configuration.PortletConfigurationServiceUt il;

import com.sun.image.codec.jpeg.JPEGCodec;

import com.sun.image.codec.jpeg.JPEGImageEncoder;

import com.sun.pdfview.PDFFile;

import com.sun.pdfview.PDFPage;

/**

* 将Word文档转换成html字符串的工具类

*

* @author MZULE

*

*/

public class ConverterUtil {

private static final String _BMS_FREE_TERMS_MANAGE_PORTLET_NAME = "BMS-FreeTermsManage-portlet";

private static final String _EXCEPTION_CONVERSION_FAILURE = "conversion_failure";

private static final String _IMG_SRC_TAG = "

private static String _SOFTWARE_UPLOAD_PATH = null;

private static Process pro = null;

public static String getFileUploadPath(Long versionid){ if(null == _SOFTWARE_UPLOAD_PATH || StringPool.BLANK.equals(_SOFTWARE_UPLOAD_PATH)){

Configuration config = PortletConfigurationServiceUtil

.getConfiguration(

PortletConfigurationServiceUtil.class.getClassLoader(),

_BMS_FREE_TERMS_MANAGE_PORTLET_NAME);

_SOFTWARE_UPLOAD_PATH = config.get("tms.apk.upload.path");

}

return _SOFTWARE_UPLOAD_PATH + versionid + StringPool.FORWARD_SLASH;

}

/**

* 上传文件

*

* @param path 上传路径

* @param fileName 上传文件名

* @param file 文件

* @throws PortalException

*/

public static String uploadFile(String path, String fileName, File file)

throws PortalException {

InputStream from = null;

FileOutputStream to = null;

File pathFile = new File(path);

if (!pathFile.exists()) {

pathFile.mkdirs();

}

pathFile = new File(path +StringPool.FORWARD_SLASH+ fileName);

try {

if (!pathFile.exists()) {

pathFile.createNewFile();

}

from = new FileInputStream(file);

to = new FileOutputStream(pathFile);

byte[] buffer = new byte[4096];

int bytes_read;

while ((bytes_read = from.read(buffer)) != -1)

to.write(buffer, 0, bytes_read);

} catch (Exception e) {

throw new PortalException();

} finally {

try {

if (null != from) {

from.close();

}

if (null != to) {

to.close();

}

} catch (IOException e) {

throw new PortalException();

}

}

return pathFile.getAbsolutePath();

}

public static File docToPdf(File docFile, String filepath) throws PortalException{

try {

startService();

File pdfFile = new File(filepath + StringPool.FORWARD_SLASH + new Date().getTime()+ ".pdf");

OpenOfficeConnection con = new SocketOpenOfficeConnection(8100);

con.connect();

DocumentConverter converter = new OpenOfficeDocumentConverter(con);

converter.convert(docFile, pdfFile);

con.disconnect();

stopService();

return pdfFile;

}

catch (Exception e) {

throw new PortalException(_EXCEPTION_CONVERSION_FAILURE);

}

}

//pdf he picturedir和docpath放在同一目录/目录根据当前版本号创建

public static int pdfToPicture(File pdfFile,String pictureDir) throws PortalException {

// "D:/test/doctest.pdf"D://test//picturehd//

int pictureSum=0;

try{

RandomAccessFile raf = new RandomAccessFile(pdfFile, "r");

FileChannel channel = raf.getChannel();

ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());

PDFFile pdffile = new PDFFile(buf);

for (int i = 1; i <= pdffile.getNumPages(); i++) { PDFPage page = pdffile.getPage(i);

Rectangle rect = new Rectangle(0, 0, (int) page.getBBox().getWidth(), (int) page.getBBox().getHeight());

Image img = page.getImage(rect.width, rect.height,rect,null,true,true);

BufferedImage tag = new BufferedImage(rect.width, rect.height,BufferedImage.TYPE_INT_RGB);

tag.getGraphics().drawImage(img, 0, 0, rect.width, rect.height,null);

FileOutputStream out = new FileOutputStream(pictureDir+StringPool.FORWARD_SLASH+ i + ".jpg"); // 输出到文件流

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);

encoder.encode(tag); // JPEG编码

out.close();

}

pictureSum=pdffile.getNumPages();

}catch(Exception e){

throw new PortalException(_EXCEPTION_CONVERSION_FAILURE);

}

return pictureSum;

}

//压缩并存储图片

public static File compressImage(File file, String directoryFileName,

int width, int height, boolean proportion) throws PortalException {

FileOutputStream fileOutputStream = null;

File compressImage=new File(directoryFileName);

try {

if (file == null || directoryFileName == null) { return null;

}

fileOutputStream = new FileOutputStream(compressImage);

Image image = ImageIO.read(file);

if (image.getWidth(null) == -1) {

return null;

}

int newWidth = 0;

int newHeight = 0;

if (image.getWidth(null) > width || image.getHeight(null) > height) {

if (proportion) {

int rate1 = image.getWidth(null) / width;

int rate2 = image.getHeight(null) / height;

int rate = rate1 > rate2 ? rate1 : rate2;

newWidth = image.getWidth(null) / rate;

newHeight = image.getHeight(null) / rate;

} else {

newWidth = width;

newHeight = height;

}

} else {

newWidth = image.getWidth(null);

newHeight = image.getHeight(null);

}

BufferedImage bufferedImage = new BufferedImage(newWidth,

newHeight, BufferedImage.TYPE_INT_RGB);

bufferedImage.getGraphics().drawImage(

image.getScaledInstance(newWidth, newHeight,

image.SCALE_SMOOTH), 0, 0, null);

JPEGImageEncoder encoder = JPEGCodec

.createJPEGEncoder(fileOutputStream);

encoder.encode(bufferedImage);

fileOutputStream.close();

} catch (Exception e) {

throw new PortalException();

} finally {

if (fileOutputStream != null) {

try {

fileOutputStream.close();

} catch (Exception e) {

throw new PortalException(_EXCEPTION_CONVERSION_FAILURE);

}

}

}

return compressImage;

}

/**

* 将word文档转换成html文档

*

* @param docFile

* 需要转换的word文档

* @param filepath

* 转换之后html的存放路径

* @return 转换之后的html文件

* @throws IOException

* @throws PortalException

*/

public static String docToHtml(File docFile, String filepath) throws TransformerException, IOException, ParserConfigurationException, PortalException {

filepath = filepath + StringPool.FORWARD_SLASH;

String htmlFileName = new Date().getTime()+ ".html";

String htmlFilePath=filepath + htmlFileName;

InputStream input = new FileInputStream(docFile);

HWPFDocument wordDocument = new HWPFDocument(input);

WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(DocumentBuilderFactory.newInstance().newDocum entBuilder().newDocument());

wordToHtmlConverter.setPicturesManager(new PicturesManager() { public String savePicture(byte[] content, PictureType pictureType, String suggestedName,

float widthInches,float heightInches) {

return suggestedName;

}

});

wordToHtmlConverter.processDocument(wordDocument);

List pics = wordDocument.getPicturesTable().getAllPictures(); if (pics != null) {

for (int i = 0; i < pics.size(); i++) {

Picture pic = (Picture) pics.get(i);

try {

pic.writeImageContent(new

FileOutputStream(filepath + pic.suggestFullFileName()));

} catch (FileNotFoundException e) {

throw new PortalException(_EXCEPTION_CONVERSION_FAILURE);

}

}

}

Document htmlDocument = wordToHtmlConverter.getDocument();

ByteArrayOutputStream outStream = new ByteArrayOutputStream(); DOMSource domSource = new DOMSource(htmlDocument);

StreamResult streamResult = new StreamResult(outStream);

TransformerFactory tf = TransformerFactory.newInstance();

Transformer serializer = tf.newTransformer();

serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");

serializer.setOutputProperty(OutputKeys.INDENT, "yes");

serializer.setOutputProperty(OutputKeys.METHOD, "html");

serializer.transform(domSource, streamResult);

outStream.close();

String content = new String(outStream.toByteArray());

OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(htmlFilePath), "UTF-8");

osw.write(content);

osw.flush();

osw.close();

//这是源文件

File htmlFile = new File(htmlFilePath);

String htmlMoveFilePath = "";

try {

htmlMoveFilePath = uploadHtmlFile(htmlFile.getName(), htmlFile);

} catch (PortalException e) {

throw new PortalException(_EXCEPTION_CONVERSION_FAILURE);

}

//FileUtils.write(new File(filepath, htmlFileName), content, "utf-8");

return htmlMoveFilePath;

}

/**

* 上传文件

*

* @param fileName 上传文件名

* @param file 源文件

* @throws PortalException

*/

public static String uploadHtmlFile(String fileName, File file) throws PortalException {

Configuration config = PortletConfigurationServiceUtil

.getConfiguration(

PortletConfigurationServiceUtil.class.getClassLoader(),

_BMS_FREE_TERMS_MANAGE_PORTLET_NAME);

String htmpservicepath = config.get("free.terms.html.path");

///upload-apk/htmlfile

String portalWebDir = System.getProperty("env.DOMAIN_HOME") + "/portal/ROOT"; //获取服务器路径

//需要移动的文件路径

htmpservicepath = portalWebDir + htmpservicepath;

//需要移动到的文件

File htmlServiceFile = new File(htmpservicepath);

if (!htmlServiceFile.exists()) {

htmlServiceFile.mkdirs();

}

htmlServiceFile = new File(htmpservicepath +StringPool.FORWARD_SLASH+ fileName);

InputStream from = null;

FileOutputStream to = null;

try {

if (!htmlServiceFile.exists()) {

htmlServiceFile.createNewFile();

}

from = new FileInputStream(file);

to = new FileOutputStream(htmlServiceFile.getPath());

byte[] buffer = new byte[4096];

int bytes_read;

while ((bytes_read = from.read(buffer)) != -1)

to.write(buffer, 0, bytes_read);

} catch (Exception e) {

throw new PortalException() ;

} finally {

try {

if (null != from) {

from.close();

}

if (null != to) {

to.close();

}

} catch (IOException e) {

throw new PortalException() ;

}

}

return htmlServiceFile.getAbsolutePath();

}

public static void startService() throws PortalException{ // 启动OpenOffice的服务 -nofirststartwizard &

String command = "/opt/openoffice4/program/soffice -headless

-accept=\"socket,host=127.0.0.1,port=8100;urp;StarOffice.Service\ " -nofirststartwizard &";

// connect to an https://www.360docs.net/doc/7a3205385.html, instance running on port 8100

try{

pro = Runtime.getRuntime().exec(command);

}catch(Exception ex){

throw new PortalException("conversion_service_unstarted") ;

}

}

public static void stopService(){

if(pro!=null){

pro.destroy();

}

}

/**

* 清除一些不需要的html标记

*

* @param htmlStr

* 带有复杂html标记的html语句

* @return 去除了不需要html标记的语句

*/

protected static String clearFormat(String htmlStr, String docImgPath) {

// 获取body内容的正则

String bodyReg = "";

Pattern bodyPattern = https://www.360docs.net/doc/7a3205385.html,pile(bodyReg);

Matcher bodyMatcher = bodyPattern.matcher(htmlStr);

if (bodyMatcher.find()) {

// 获取BODY内容,并转化BODY标签为DIV

htmlStr = bodyMatcher.group().replaceFirst("", "

");

}

// 调整图片地址

htmlStr = htmlStr.replaceAll(_IMG_SRC_TAG, _IMG_SRC_TAG + docImgPath

+ StringPool.FORWARD_SLASH);

// 把

转换成
保留样式

// content = content.replaceAll("(]*>.*?)(<\\/P>)",

// "");

// 把

转换成并删除样式

htmlStr = htmlStr.replaceAll("(]*)(>.*?)(<\\/P>)", "");

// 删除不需要的标签

htmlStr = htmlStr

.replaceAll(

"<[/]?(font|FONT|span|SPAN|xml|XML|del|DEL|ins|INS|meta|META|[ovw xpOVWXP]:\\w+)[^>]*?>",

"");

// 删除不需要的属性

htmlStr = htmlStr

.replaceAll(

"<([^>]*)(?:lang|LANG|class|CLASS|style|STYLE|size|SIZE|face|FACE |[ovwxpOVWXP]:\\w+)=(?:'[^']*'|\"\"[^\"\"]*\"\"|[^>]+)([^>]*)>", "<$1$2>");

return htmlStr;

}

}

为什么我用word文档转换成html格式后表格边框不见了

竭诚为您提供优质文档/双击可除 为什么我用word文档转换成html格式 后表格边框不见了 篇一:word格式转换html 将word格式的文件转换成html格式的网页文件详细步骤: 1、首先建立一个word文档,并在上面编辑好自己想要创建网页的内容,如下图: 2、点击“文件”下拉菜单,并在下拉菜单中选择“另存为”命 令 3、页面出现下图所示的窗口, 4、点击保存类型中的三角形下拉菜单,得到下图所示的窗口 , 5、选择“网页文件(*html,*htm)”命令,给文件命名为“教育.html”并点击“保存”;即完成了“word”转换成“html”网页格式(为什么我用word文档转换成html格式后表格边框不见了)的过程:

7、寻找下图两个文件,双击打开后缀名为html的文件,如这里的“教育.html”文件,即可看到我们转换的html网页了。 篇二:word转html后的变化 word文档转换为html文档后的变化 办公软件 palign="left">当用户将word文档存为web页时,word 会关闭文档,然后用超文本标记语言(html)格式保存,但是因为html不支持某些word功能,转换时word会更改或取消内容,因此应先用word格式保存文档。特别是当文档还要当作word文档使用时。本人通过实践和搜集,对word文档转换成html时发生的变化列出如下表,希望能给广大网页设计爱好者一点帮助。 篇三:word文档格式html制作规则 word文档格式html制作规则 一、制作要求 文书制作应当完整、准确、规范,符合相关要求。 除有特别要求的文书外,文书尺寸统一使用a4 (210mm*297mm)纸张印制。 1、文书使用3号黑体; 2、文书名称使用2号宋体; 3、表格内文字使用5号仿宋。需加盖公章的制作式文

C# Word转PDF、TXT、图片、HTML

C# Word转PDF、TXT、图片、HTML 使用MS Word时,用户点击“文档”-“另存为”,即可将新建的或现有的Word文档保存为PDF、TXT、HTML 等格式文档。如何通过编程的方式实现Word的转换功能呢? 在C#中对文档进行转换,我们需要使用到Interop.Word或其他第三方类库。使用Interop.Word,需要安装Microsoft Office,各种配置十分麻烦。本文为大家介绍使用免费版的Spire.Doc组件实现Word文档格式转换。 该组件提供的可用于格式转换的方法有: 下载Spire.Doc后,引用Spire.Doc.dll到Visual Studio,并在程序开头添加以下命名空间即可。 using System; using Spire.Doc; using System.Drawing; 然后,就可以通过下面的代码进行格式转换:

一,Word转PDF //初始化Document实例 Document doc = new Document(); //加载Word文档 doc.LoadFromFile("个人简历.docx"); //保存为PDF doc.SaveToFile("个人简历.pdf", FileFormat.PDF); 二,Word转HTML //初始化Document实例 Document doc = new Document(); //加载Word文档 doc.LoadFromFile("个人简历.docx"); //保存为HTML doc.SaveToFile("个人简历.html", FileFormat.Html); 三,Word转TXT //初始化Document实例 Document doc = new Document(); //加载Word文档 doc.LoadFromFile("个人简历.docx"); //保存为Text文档 doc.SaveToFile("个人简历.txt", FileFormat.Txt);

将Word文档转换成图片PDF的办法

将Word文档转换成图片PDF的办法 很多人都想把Word文档转换成图片格式的PDF文档,保证无法拷贝文档里的文字,以保护知识产权,但是苦于找不到合适的办法。网上有可以完成这个任务的软件,但是要收费,效果也不好。经探索,我总结出了以下较为便捷(而且绝对免费)的转换方法,不需特别的软件,只需要Word和Adobe Acrobat两种基本软件就可以得到效果很好的图片PDF文档。 第一步:在word软件里利用“另存为”或虚拟打印机把word 文档转换成非图片格式的PDF文档。这个比较简单,不细说。 第二步:在Adobe Acrobat Pro里打开菜单栏的“文件”—“导出”—“图像”—“JPEG”,把PDF转换成一张一张的jpg图片, 版式阅读软件,云签章,可信时间戳

全部放在同一个文件夹下。 第三步:在Adobe Acrobat Pro里打开菜单栏的“文件”—“创建PDF”—“组合文件到单个PDF”,点“添加文件”,选择“添加文件夹”,选择刚才存放JPG图片的文件夹,往下操作就变成图片PDF了。 注意事项:生成JPG图片时可以设置图片质量,不要把图片质量设太高,否则体积太大、速度太慢。有一半的质量,转换之后每张图片几百K,看起来效果就很好了。 躬行文件转换迁移系统为各类应用系统提供长期驻留的文档格式转换服务,可采用实时、批量或套转方式将各种格式文档转换为PDF或OFD文件,支持的格式包括但不限于微软Office办公文档系列、WPS、PDF、XPS、图片、RTF、HTML网页等。内置多种转换引擎,支持集群配置,可有效应对高精度、大数据量、高速度、高可靠性要求的文档转换需求。支持以WebApi方式调用。 河南省躬行信息科技有限公司位于郑州高新技术开发区,是一家以信息技术为核心的高科技企业。公司以信息安全技术为特色,秉承"优质服务,互利共赢"的理念,提供软件与系统开发、信息安全保密、Web应用安全等开发和咨询服务。期待您的详询。 版式阅读软件,云签章,可信时间戳

教你如何将Word文档转化为图片

教你如何将Word文档转化为图片(一) 数学试卷中的许多公式与符号难以黏贴到研修平台,许多学员非常不便,笔者通过研究与实验。向大家推荐以下方法: 法一、打开要转化为图片的Word文档-编辑-全选-复制-新建-编辑-选择性粘贴-图片(调整画面的大小),即可得到你要的图片,此法的图片仍在word文档中。 法二、如果要保存为独立的Word的图片,则继续在刚才的新建Word文档中-右键-复制-打开-附件-画图-编辑-粘贴—保存(可选择类型,研修平台需用*.jpg *.gif格式),这种方法一次只能够将Word文档中一页的文字转化为一张图片(调整画面的大小) 法三、最简单的方法是直接把DOC文档直接拖入word窗口中,文档的第一页且只有第一页显示并转化为图片格式,你只需将原文档,删除第一页后,保存,再将其第二次拖入word窗口中,这时第二页也就以图片的格式呈现在了窗口中,再在原word文档中删除最前一页后,保存……如何往复,直到最后一页以图片格式呈现于窗口中,最后整个word 文档就都转化为了一页页的图片。然后分别将每一页再复制到“开始-程序-附件-图画”中,将其保存为图片,最后上传即可。(调整画面的大小) 大家用一下,感觉很好。 大家交流 如下图:笔者实验图例 教你如何将Word文档转化为图片(一) 数学试卷中的许多公式与符号难以黏贴到研修平台,许多学员非常不便,笔者通过研 究与实验。向大家推荐以下方法: 法一、打开要转化为图片的Word文档-编辑-全选-复制-新建-编辑-选择性 粘贴-图片(调整画面的大小),即可得到你要的图片,此法的图片仍在word文档中。 法二、如果要保存为独立的Word的图片,则继续在刚才的新建Word文档中-右键 -复制-打开-附件-画图-编辑-粘贴—保存(可选择类型,研修平台需用*.jpg *.gif格 式),这种方法一次只能够将Word文档中一页的文字转化为一张图片(调整画面的大小) 法三、最简单的方法是直接把DOC文档直接拖入word窗口中,文档的第一页且只 有第一页显示并转化为图片格式,你只需将原文档,删除第一页后,保存,再将其第二次拖 入word窗口中,这时第二页也就以图片的格式呈现在了窗口中,再在原word文档中删除 最前一页后,保存……如何往复,直到最后一页以图片格式呈现于窗口中,最后整个word 文档就都转化为了一页页的图片。然后分别将每一页再复制到“开始-程序-附件-图画” 中,将其保存为图片,最后上传即可。(调整画面的大小) 大家用一下,感觉很好。 大家交流

word转图片在线转换 在线将Word文档转换至JPG图片

word转图片在线转换在线将Word文档转换至JPG图片 Word文件和图片都是在我们生活中和工作中经常会遇到的,一般来说我们想要将Word转图片怎么操作?不单单只是利用截图工具就可以,其实我们还需要操作的技巧有很多,那么如何将word转图片在线转换?在线将Word文档转换至JPG图片有怎么操作呢? 其实方法很简单,小编今天就简单教你们操作方法 所需工具 1.Word文件 2.Word转JPG https://www.360docs.net/doc/7a3205385.html,/word2jpg 步骤/方法 1.首先我们在百度浏览器中进行搜索“迅捷PDF在线编辑器”然后进行点击,我们就可以 看到他的搜索页面 2.我们选择进入之后可以看到他的一些操作页面,我们可以看到他的一些操作功能,我们 进行点击

3.我们进行点击,选择“文档转换”——“Word转图片操作”我们可以看到他的一些跳 转页面 4.页面跳转之后我们就可以看到文件上传的页面,我们进行点击“点击选择页面”进行文 件的上传

5.我们可以看到它底下的一些设置,我们将Word转换为图片的时候可以选择转换的页码 和转换的格式以及他的背景颜色和图片的方向以及文件是否公开! 6.文件上传完之后进行设置我们就可以件文件的转换,点击右下角的“开始转换”就可以 将Word文件转换为图片格式了

7.将文件转换好之后我们既可进行保存到电脑上或者进行扫码下载到自己手机既可完成 操作! 今天的分享就到这里,操作很简单,小伙伴们可以利用迅捷PDF在线编辑器去对PDF文件或者Word文件以及excel等文件去进行编辑,操作的方法很简单,小伙伴们可以去尝试一下,希望对你们能够有所帮助!

POI读取word转换html

POI读取word转换html 文章分类:Java编程 apache POI读取word文档的文档比较少,所以只有自己慢慢的摸索,这篇文章也属于比较基础入门的,主要是针对读取word中的图片,以及文字的各种样式,如有不好的地方,请各位多多指教! Java代码 1./** 2. * 3. */ 4.package com.util; 5. 6.import java.io.BufferedWriter; 7.import java.io.File; 8.import java.io.FileInputStream; 9.import java.io.FileNotFoundException; 10.import java.io.FileOutputStream; 11.import java.io.IOException; 12.import java.io.OutputStream; 13.import java.io.OutputStreamWriter; 14. 15.import org.apache.poi.hwpf.HWPFDocument; 16.import org.apache.poi.hwpf.model.PicturesTable; 17.import https://www.360docs.net/doc/7a3205385.html,ermodel.CharacterRun; 18.import https://www.360docs.net/doc/7a3205385.html,ermodel.Picture; 19.import https://www.360docs.net/doc/7a3205385.html,ermodel.Range; 20. 21./** 22. * 23. * @author 张廷下午10:36:40 24. * 25. */ 26.public class WordToHtml { 27. 28./** 29. * 回车符ASCII码 30. */ 31.private static final short ENTER_ASCII = 13; 32. 33./** 34. * 空格符ASCII码 35. */ 36.private static final short SPACE_ASCII = 32; 37. 38./**

Word文档转换为HTML帮助文档操作手册

Word文档转换为HTML帮助文档操作手册 一、使用到的软件 ●DOC2CHM ●Dreamweaver CS3 ●Help and manual 4 二、操作步骤 1. 先建立一个工作目录。如hhwork。 2.将需要转换的文件复制到此工作目录下。如果是中文文件名,最好将其改为英文文件名。例:现在要将《小神探点检定修信息管理系统使用手册0. 3.6.doc》转换为Html格式的帮助文档,首先将此文档复制到hhwork目录下并将其更名为manual36.doc。如图1所示。 图1 3.打开软件DOC2CHM,然后找到manual36.doc,然后点击“Convert”按钮,如图2所示。

图2 4. 程序分析文档后,打开如图3所示的界面。 图3 5. 在图3所示的界面中选择默认的“Outline”,然后点击“Last>>”

按钮,打开图4所示的界面。 图4 6. 在图4所示的界面中点击“Convert”按钮,程序开始将文档Manual36.doc转换为Html文档,并保存在Manual36子目录下。 7. 在子目录下的以Outline开头的文件夹下,将后缀名为jpg的文件名更改一下,目的是每个文件的名称不同。 8. 用Dreamweaver打开此目录中的所有htm文件,如图5。

图5 9. 在图5所示的界面中将出现在标题前的标签删除掉,然后将标题复制到标题框中。然后将图片的链接更改正确。 10. 打开Help and Manual 4,如图6。 图6

11. 在图6所示的界面中点击“新建”按钮创建新的帮助方案。如图7所示。 图7 12. 在图7所示的界面中选择“导入现有的文件从…”,然后选择“常规HTML和文本文件”,在下面的框中指定源文件夹的位置。然后点击“下一步”。程序打开图8所示的界面。 图8 13. 在上图中指定输出文件的位置,可以采用默认位置。然后点击“下

word域代码转换html丢失解决办法

Word转html存在域代码丢失。 Aspose ,jacob,poi都无法解决 在使用jocob转换成html时域代码会被包裹 可以统一提取出来转换成latex ,latex转换成图片,解决word域代码丢失问题 private void processFormula(List nodes) throws UnsupportedEncodingException{ for(int i = nodes.size()-1;i>=0;i--){ Node node =nodes.get(i); if(node instanceof Element){ Element e = (Element)node; processFormula(e.childNodes()); }else if(node instanceof Comment){ String commentText = node.toString(); if(commentText.contains("