页眉页脚在word文档的第一页上重复

header footer repeating on first page of word document

我想从 HTML 获取 word 文件。我面临的问题是页眉和页脚在 body.Is 中单词的第一页上重复,可以解决删除或隐藏 table 的问题。 我试过使用 margin 属性 但在页眉和正文之间留空 space (我将在屏幕截图中显示)。 enter image description here 我正在使用的代码: HTML :

<div class="main">
        <table id='hrdftrtbl' border='1' cellspacing='0' cellpadding='0'>
            <tr>
                <td>
                    <div class="header" style='mso-element:header' id="header1">
                        <p class="MsoHeader">
                            <table  style="float: right;width: 100%;">
                                <tbody>
                                    <tr>
                                        <td align="right">
                                            <!--<img src="{!URLFOR($Resource.PDF,'PDF/AdaniPort.png')}" style="float: right;" />-->
                                            <img src="https://adanicf--portsdev--c.cs5.content.force.com/servlet/servlet.ImageServer?id=015O00000031R1i&oid=00DO000000555mR&lastMod=1565955266000"  height='80' width='60'  style="float: right;width=2% !important;height=6% !important"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right"><b>{!LogoPortName}</b>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <hr size="2" style="color: black;" />
                                        </td>
                                    </tr>
                                    
                                </tbody>
                        </table></p>
                </div>
        </td>
        <td>
            <div class="footer" style='mso-element:footer' id="footer1">
                <p class="MsoFooter">
                    <!-- <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div> -->
                    <table id="ftrtbl" style="float: right;width: 100%;">
                        <tr>
                            <td colspan="2">
                                <hr size="2" style="color: black;" />
                            </td>
                        </tr>
                        <tr>
                            <td style="width:40%;font-size:14px;" align="left" >This Document is strictly confidential</td>
                            <td style="width:40%;font-size:14px;" align="left" >{!quote.Ref_No__c}</td>
                            <td style="width:20%;font-size:14px;" align="right"> Page <span style='mso-field-code: PAGE '></span> of <span style='mso-field-code: NUMPAGES '></span><span class="pagenumber" />
                            </td>
                        </tr>
                </table>
            </p>
        </div>
    </td>
</tr>

CSS(使用保证金):

 @page main {
                mso-header:header1;
                mso-footer:footer1;
                mso-paper-source:0;
                
                mso-header-margin:0.5in;
                mso-footer-margin:0.5in;
                }
                div.main {
                page:main;
                }
                p.MsoFooter, li.MsoFooter, div.MsoFooter {
                mso-pagination:widow-orphan;
                tab-stops:center 216.0pt right 432.0pt;
                }
                p.MsoHeader, li.MsoHeader, div.MsoHeader {
                mso-pagination:widow-orphan;
                width:1px;
                height:1px;
                }
                table#hrdftrtbl{
 margin:50in 0in 0in 15in;} 

            

已回答请检查link

How to use HTML to print header and footer on every printed page of a document?

thead: 这是为了重复header.

tfoot: 重复的页脚。

正文: 内容。

我还没有找到合适的解决方案,但对我有用的技巧是我更改了 body 标签下方的页眉-页脚代码的位置,以便空的 space 将从第一页移到最后一页.

exp: 之前:

<div class="main">
---------
-----------
</div>

<body>
----------
----------
</body>

之后:

<body>
----------
----------
</body>
<div class="main">
---------
-----------
</div>