0

如何使用 mime 类型 application/msword 将页码添加到动态生成的文档中?

4

1 回答 1

2

是的,您可以在动态生成的文档中添加页码。获取代码打开一个新文档在页眉/页脚中启用页码,将其保存为单页网页(* .htm)在任何文本编辑器(例如记事本)中打开生成的文件分析代码并获取显示页面的代码数字。在这里,我尝试将页码显示为第 1 页,共 15 页。这是我从 *.htm 文件中获得的代码 注意:您可能还需要复制相关的样式。

<style>
 @page Section1
{
    size:11.0in 8.5in;
    mso-footer: url("http://images/footer.htm")f1; 
    mso-header: url("http://images/header.htm")h1;      
    mso-page-orientation:landscape;
    margin:0.3in 0.5in 0.4in 0.5in;
    mso-header-margin:.2in;
    mso-footer-margin:.2in;
    mso-paper-source:0;
    font-family:Gill Sans MT, Times New Roman, Trebuchet MS;
}
div.Section1
{ page:Section1;}
@page Section2
{
    size:11.0in 8.5in; 
    mso-footer: url("http://images/footer.htm")f1; 
    mso-header: url("http://images/header2.htm")h2;         
    mso-page-orientation:landscape;
    margin:0.3in 0.5in 0.4in 0.5in;
    mso-header-margin:.2in;
    mso-footer-margin:.2in;
    mso-paper-source:0;
    font-family:Gill Sans MT, Times New Roman, Trebuchet MS;
}
   </style> 
  ------------- 

  ------=_NextPart_000_0019_01CA5EDF.DC424910
   Content-Type: text/html;
   charset="iso-8859-1"
   Content-Transfer-Encoding: quoted-printable
   Content-Location: http://images/footer.htm

    <!--[if supportFields]>
   <div style=3D'mso-element:footer;' id=3D'f1'>
  <p class=3D'MsoFooter' style=3D'border:none;mso-border-bottom-alt:solid windowtext    .75pt;padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'>
   <table border=3D"0" width=3D"100%" cellpadding=3D"0" cellspacing=3D"0">
                    <tr>

                        <td width=3D"25%" align=3D"right"style=3D"font-family:Gill Sans MT, Times New Roman, Trebuchet MS;font-size:16pt;color:#6cbc48;font-weight:bold;padding:7px 30px 0px 0px;" valign=3D"middle">
                           Page <span style=3D'**mso-field-code: PAGE**' ></span> of <span style=3D'**mso-field-code:NUMPAGES** '></span>&nbsp;
                        </td>

                </tr>
            </table>

于 2011-05-05T08:17:59.460 回答