我想通過使用JavaScript將HTML轉換爲word(.docx)。我正在使用此http://www.jqueryscript.net/other/Export-Html-To-Word-Document-With-Images-Using-jQuery-Word-Export-Plugin.html插件進行轉換。但是這只是轉換HTML文件中的每一件東西。我的意思是頭部標記所有元素,即使有一些內容。輸出文件看起來像這樣將HTML轉換爲使用javascript的詞轉換
的MIME版本:1.0內容基地: 文件:///home/userprofile/JsWs/sample.html的Content-Type: 多部分/相關; border =「NEXT.ITEM-BOUNDARY」; type =「text/html」
--NEXT.ITEM-BOUNDARY Content-Type:text/html;字符集= 「UTF-8」 內容位置:文件:///home/userprofile/JsWs/sample.html
<p>this is going to be paragraph </p> </body></html>
--NEXT.ITEM-BOUNDARY--
和我的HTML是
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="FileSaver.js"></script>
<script src="jquery.wordexport.js"></script>
</head>
<body>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("a.word-export").click(function(event) {
$("#export-content").wordExport();
});
});
</script>
<div id="export-content">
<p>this is going to be paragraph </p>
</div>
<a class="word-export" href="javascript:void(0)"> Export as .doc </a>
</body>
</html>
幫助我如何轉換Word中的HTML內容。
我會建議你使用名爲Docverter的API。它允許您將HTML轉換爲DOCX。 – kovogel
或使用https://github.com/evidenceprime/html-docx-js –