HTML 生成的 Microsoft Word 文档,带有页眉、页脚和水印 [英] HTML generated Microsoft Word document with header, footer and watermark

查看:35
本文介绍了HTML 生成的 Microsoft Word 文档,带有页眉、页脚和水印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找由 HTML 生成的 Microsoft Word 文档的示例.它应该包含页眉、页脚和水印.

解决方案

这是一些示例,希望能帮助到其他正在尝试使用 HTML 生成 ms word .doc 文件的人.

<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><title></title><风格>v:* {behavior:url(#default#VML);}o:* {behavior:url(#default#VML);}w:* {behavior:url(#default#VML);}.shape {behavior:url(#default#VML);}</风格><风格>@页{mso-page-orientation:横向;尺寸:29.7cm 21cm;边距:1cm 1cm 1cm 1cm;}@页面第1部分{mso-header-margin:.5in;mso-footer-margin:.5in;mso-header: h1;mso-页脚:f1;}div.Section1 { 页:Section1;}表#hrdftrtbl{边距:0in 0in 0in 900in;宽度:1px;高度:1px;溢出:隐藏;}p.MsoFooter, li.MsoFooter, div.MsoFooter{边距:0in;边距底部:.0001pt;mso-分页:寡妇孤儿;制表位:中心 3.0 英寸,右 6.0 英寸;字体大小:12.0pt;}</风格><xml><w:WordDocument><w:View>打印</w:View><w:Zoom>100</w:Zoom><w:DoNotOptimizeForBrowser/></w:WordDocument></xml><身体><div class="Section1"><p>&nbsp;</p><br/><table id='hrdftrtbl' border='0' cellspacing='0' cellpadding='0'><tr><td><div style='mso-element:header' id=h1 ><!-- HEADER-tags --><p class=MsoHeader >HEADER</p><!-- 结束 HEADER-tags -->

</td><td><div style='mso-element:footer' id=f1><span style='position:relative;z-index:-1'><!-- 页脚标签-->页脚<span style='mso-no-proof:yes'><!--[if gte vml 1]><v:shapetypeid="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"path="m@4@5l@4@11@9@11@9@5xe"filled="f"stroked="f"><v:公式><v:f eqn="if lineDrawn pixelLineWidth 0"/><v:f eqn="sum@0 1 0"/><v:f eqn="sum 0 0 @1"/><v:f eqn="prod @2 1 2"/><v:f eqn="prod @3 21600 pixelWidth"/><v:f eqn="prod @3 21600 pixelHeight"/><v:f eqn="sum@0 0 1"/><v:f eqn="prod @6 1 2"/><v:f eqn="prod @7 21600 pixelWidth"/><v:f eqn="sum@8 21600 0"/><v:f eqn="prod @7 21600 pixelHeight"/><v:f eqn="sum@10 21600 0"/></v:公式><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/><o:lock v:ext="edit" aspectratio="t"/></v:shapetype><v:shape id="Picture_x0020_1" o:spid="_x0000_s3073" type="#_x0000_t75"alt="VHB" style='position:absolute;边距右:0pt;边距顶部:-400pt;z-索引:-1;可见性:可见;mso-wrap-style:square;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizo​​ntal:absolute;mso-position-horizo​​ntal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text'><v:imagedata src="https://www.google.bg/logos/2012/Rodin-2012-homepage.png"/></v:shape><![endif]--></span><p class=MsoFooter><span style='mso-tab-count:2'></span>页面<span style='mso-field-code: PAGE'><span style='mso-no-proof:yes'></span>来自 <span style='mso-field-code: NUMPAGES'></span><!-- 结束 FOOTER-tags --></span></p>

<div style='mso-element:header' id='fh1'><p class='MsoHeader'><span lang='EN-US' style='mso-ansi-language:EN-US'><o:p></o:p></span></p>

<div style='mso-element:footer' id='ff1'><p class='MsoFooter'><span lang='EN-US' style='mso-ansi-language:EN-US'><o:p></o:p></span></p>

</td></tr>

</body></html>

可以通过在元素 v:shape id="Picture_x0020_1" : inline style 上设置宽度、高度、margin-top、margin-right来调整水印图片.

I'm looking for an example of a Microsoft Word Document generated by HTML. It should contain a header, footer and a watermark.

解决方案

This is some example, hope it helps others that are trying to generate ms word .doc file with HTML.

<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="http://www.w3.org/TR/REC-html40">
<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><title></title>
<style>
v:* {behavior:url(#default#VML);}
o:* {behavior:url(#default#VML);}
w:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<style>
@page
{
    mso-page-orientation: landscape;
    size:29.7cm 21cm;    margin:1cm 1cm 1cm 1cm;
}
@page Section1 {
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-header: h1;
    mso-footer: f1;
    }
div.Section1 { page:Section1; }
table#hrdftrtbl
{
    margin:0in 0in 0in 900in;
    width:1px;
    height:1px;
    overflow:hidden;
}
p.MsoFooter, li.MsoFooter, div.MsoFooter
{
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    tab-stops:center 3.0in right 6.0in;
    font-size:12.0pt;
}
</style>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>100</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
</head>

<body>
<div class="Section1">

    <p>&nbsp;</p>
<br/>
    <table id='hrdftrtbl' border='0' cellspacing='0' cellpadding='0'>
    <tr><td>        <div style='mso-element:header' id=h1 >
        <!-- HEADER-tags -->
            <p class=MsoHeader >HEADER</p>
        <!-- end HEADER-tags -->
        </div>
    </td>
    <td>
    <div style='mso-element:footer' id=f1><span style='position:relative;z-index:-1'> 
        <!-- FOOTER-tags -->
        FOOTER

        <span style='mso-no-proof:yes'><!--[if gte vml 1]><v:shapetype
         id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
         path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
         <v:formulas>
          <v:f eqn="if lineDrawn pixelLineWidth 0"/>
          <v:f eqn="sum @0 1 0"/>
          <v:f eqn="sum 0 0 @1"/>
          <v:f eqn="prod @2 1 2"/>
          <v:f eqn="prod @3 21600 pixelWidth"/>
          <v:f eqn="prod @3 21600 pixelHeight"/>
          <v:f eqn="sum @0 0 1"/>
          <v:f eqn="prod @6 1 2"/>
          <v:f eqn="prod @7 21600 pixelWidth"/>
          <v:f eqn="sum @8 21600 0"/>
          <v:f eqn="prod @7 21600 pixelHeight"/>
          <v:f eqn="sum @10 21600 0"/>
         </v:formulas>
         <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
         <o:lock v:ext="edit" aspectratio="t"/>
        </v:shapetype><v:shape id="Picture_x0020_1" o:spid="_x0000_s3073" type="#_x0000_t75"
         alt="VHB" style='position:absolute;
         margin-right:0pt;margin-top:-400pt;
         z-index:-1;
         visibility:visible;mso-wrap-style:square;mso-wrap-distance-left:9pt;
         mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;
         mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;
         mso-position-horizontal-relative:text;mso-position-vertical:absolute;
         mso-position-vertical-relative:text'>
         <v:imagedata src="https://www.google.bg/logos/2012/Rodin-2012-homepage.png"/>
        </v:shape><![endif]--></span>
           <p class=MsoFooter>
           <span style='mso-tab-count:2'></span>
           Page <span style='mso-field-code: PAGE'><span style='mso-no-proof:yes'></span> from <span style='mso-field-code: NUMPAGES'></span>

        <!-- end FOOTER-tags -->
   </span>


        </p>
    </div>



    <div style='mso-element:header' id='fh1'>
        <p class='MsoHeader'><span lang='EN-US' style='mso-ansi-language:EN-US'>&nbsp;<o:p></o:p></span></p>
        </div>
        <div style='mso-element:footer' id='ff1'>
        <p class='MsoFooter'><span lang='EN-US' style='mso-ansi-language:EN-US'>&nbsp;<o:p></o:p></span></p>
    </div>

    </td></tr>
    </table>
</div>

</body></html>

You can adjust the watermark picture by setting width, height, margin-top, margin-right on the element v:shape id="Picture_x0020_1" : inline style.

这篇关于HTML 生成的 Microsoft Word 文档,带有页眉、页脚和水印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆