使用freemarker生成的word文档,如何转成标准格式的word?

使用freemarker生成的word文档,如何转成标准格式的word?

freemarker生成的word转成PDF后,图片丢失。

所以想到将freemarker生成的xml格式的word转成标准格式的word在转成PDF。

现在不知道怎么将xml格式的word转成标准格式的word。

求帮忙啊!

文件已经解决。不适用freemarker生成word了。。用poi替换关键字,继续使用原生的word。

难道poi 不是操作ftl么 生成的不是xml么

public static boolean freeMakerWordToWord(String source,String target){
WordTOPdf pdf = new WordTOPdf();
System.out.println("FreemakerWord转Word开始启动...");
long start = System.currentTimeMillis();
ActiveXComponent app = null;
Dispatch doc = null;
try {
app = new ActiveXComponent("Word.Application");
app.setProperty("Visible", false);
Dispatch documents = app.getProperty("Documents").toDispatch();
// 打开FreeMarker生成的Word文档
doc = Dispatch.call(documents, "Open", source, false, true).toDispatch();
File tofile = new File(target);
if (tofile.exists()) {
tofile.delete();
}
// 另存为新的Word文档
Dispatch.call(doc, "SaveAs", target, 12);
Dispatch.call(doc, "Close", false);
System.out.println("FreemakerWord转Word结束...");
return true;
} catch (Exception e) {
System.out.println("FreemakerWord转Word出错:" + e.getMessage());
return false;
} finally {
if (app != null) {
app.invoke("Quit", new Variant[]{});
// app.invoke("Quit", wdDoNotSaveChanges);
}
ComThread.Release();
//关闭winword.exe进程
String command = "taskkill /f /im WINWORD.EXE";
try {
Runtime.getRuntime().exec(command);
} catch (Exception e) {
e.printStackTrace();
}

    }
}