本文整理汇总了Java中org.apache.poi.hwpf.converter.WordToHtmlUtils类的典型用法代码示例。如果您正苦于以下问题:Java WordToHtmlUtils类的具体用法?Java WordToHtmlUtils怎么用?Java WordToHtmlUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WordToHtmlUtils类属于org.apache.poi.hwpf.converter包,在下文中一共展示了WordToHtmlUtils类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.poi.hwpf.converter.WordToHtmlUtils; //导入依赖的package包/类
public static void main(String[] args)throws Exception
{
HWPFDocumentCore wordDocument = WordToHtmlUtils.loadDoc(new FileInputStream("data/document.doc"));
WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(
DocumentBuilderFactory.newInstance().newDocumentBuilder()
.newDocument());
wordToHtmlConverter.processDocument(wordDocument);
Document htmlDocument = wordToHtmlConverter.getDocument();
ByteArrayOutputStream out = new ByteArrayOutputStream();
DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(out);
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);
out.close();
FileOutputStream outputStream = new FileOutputStream("data/Apache_DocToHTML.html");
outputStream.write(out.toByteArray());
outputStream.close();
System.out.println("Apache - Doc file converted in specified formats");
}
示例2: main
import org.apache.poi.hwpf.converter.WordToHtmlUtils; //导入依赖的package包/类
public static void main(String[] args)throws Exception
{
String dataPath = "src/featurescomparison/workingwithdocuments/converttoformats/data/";
HWPFDocumentCore wordDocument = WordToHtmlUtils.loadDoc(new FileInputStream(dataPath + "document.doc"));
WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(
DocumentBuilderFactory.newInstance().newDocumentBuilder()
.newDocument());
wordToHtmlConverter.processDocument(wordDocument);
Document htmlDocument = wordToHtmlConverter.getDocument();
ByteArrayOutputStream out = new ByteArrayOutputStream();
DOMSource domSource = new DOMSource(htmlDocument);
StreamResult streamResult = new StreamResult(out);
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);
out.close();
FileOutputStream outputStream = new FileOutputStream(dataPath + "Apache_DocToHTML_Out.html");
outputStream.write(out.toByteArray());
outputStream.close();
System.out.println("Apache - Doc file converted in specified formats");
}