|
@@ -832,10 +832,14 @@ public final class DocxProcessUtil {
|
|
|
*/
|
|
|
public static String html2Docx(WordprocessingMLPackage wordMLPackage,String html)throws Exception {
|
|
|
initTmpPackage(wordMLPackage);
|
|
|
+ RFonts rfonts = Context.getWmlObjectFactory().createRFonts();
|
|
|
+ rfonts.setAscii("eastAsia");
|
|
|
+ XHTMLImporterImpl.addFontMapping("eastAsia", rfonts);
|
|
|
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
|
|
|
+ XHTMLImporter.setHyperlinkStyle("Hyperlink");
|
|
|
String wordMl = "";
|
|
|
wordMLPackage.getMainDocumentPart().getContent().addAll(
|
|
|
- XHTMLImporter.convert( repairHtmlStr(html), null) );
|
|
|
+ XHTMLImporter.convert( repairHtmlStr(html), TEMP_FILE_IMP) );
|
|
|
|
|
|
List<Object> pList = getAllElementFromObject(wordMLPackage.getMainDocumentPart(), P.class);
|
|
|
for(Object p:pList){
|
|
@@ -846,7 +850,7 @@ public final class DocxProcessUtil {
|
|
|
return wordMl;
|
|
|
}
|
|
|
|
|
|
- public static String repairHtmlStr(String htmlStr){
|
|
|
+ public static String repairHtmlStr(String htmlStr)throws Exception{
|
|
|
htmlStr = htmlStr.trim();
|
|
|
if(htmlStr.toLowerCase().contains("<!doctype html ")){
|
|
|
int index1 = htmlStr.toLowerCase().indexOf("<!doctype html ");
|
|
@@ -888,7 +892,7 @@ public final class DocxProcessUtil {
|
|
|
imgIndex = indexOfRegex(htmlStr,"<((img)|(IMG)) ",flag);
|
|
|
}
|
|
|
}
|
|
|
- return htmlStr;
|
|
|
+ return new String(htmlStr.getBytes("UTF-8"));
|
|
|
}
|
|
|
|
|
|
|