如何在javascript中将图像添加到word文件中

fquxozlt  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(319)

这是从javascript函数创建word文件的部分代码
我想在文件中添加一个映像(映像必须是服务器硬盘上的物理映像,而不是internet上的url)
如何做到这一点

var templateHeader = '<html xmlns:v="urn:schemas-microsoft-com:vml"\
                                xmlns:o="urn:schemas-microsoft-com:office:office"\
                                xmlns:w="urn:schemas-microsoft-com:office:word"\
                                xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"\
                                xmlns:css="http://macVmlSchemaUri" xmlns="http://www.w3.org/TR/REC-html40">\
                                <head>\
                                <meta name=Title content="">\
                                <meta name=Keywords content="">\
                                <meta http-equiv=Content-Type content="text/html; charset=unicode">\
                                <meta name=ProgId content=Word.Document>\
                                <meta name=Generator content="Microsoft Word 14">\
                                <meta name=Originator content="Microsoft Word 14">\
                                <link rel=File-List href="Customer%20(5)_files/filelist.xml">\
                                <!--[if gte mso 9]><xml>\
                                 <w:WordDocument>\
                                  <w:View>Print</w:View>\
                                 </w:WordDocument>\
                                </xml><![endif]-->\
                                <style>';

            templateHeader += '<!--@page WORDSECTION1 {mso-page-orientation:potrait;} -->';

        templateHeader += '</style></head><body bgcolor=white lang=EN-US style=\'tab-interval:36.0pt\'><div class=WordSection1>';
        var templateFooter = '<p class=MsoNormal style=\'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto\'><span style=\'mso-fareast-font-family:"Times New Roman";mso-bidi-font-family:"Times New Roman"\'><o:p>&nbsp;</o:p></span></p></div></body></html>';

        var charset = document.characterSet || document.charset;

        saveAs(new Blob(["\ufeff", templateHeader + "This is my file" + templateFooter], {
            type: 'application/msword;charset='+ charset,
            encoding: charset
        }), "filename" + '.doc');

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题