2013-05-30 46 views
1

我試圖從this solution創建MS Word文檔頁腳。 沒關係,頁腳看起來不錯,但頁腳文本在文檔主體中重複。 我該如何刪除它?Word XML文檔重複頁腳

截圖文件:http://d.pr/i/GR4U

和代碼的文件:

<html xmlns:o="urn:schemas-microsoft-com:office:office" 
     xmlns:w="urn:schemas-microsoft-com:office:word" 
     xmlns="http://www.w3.org/TR/REC-html40"> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> 
     <!--[if gte mso 9]> 
      <xml> 
       <w:WordDocument> 
        <w:View>Print</w:View> 
        <w:Zoom>90</w:Zoom> 
        <w:DoNotOptimizeForBrowser/> 
       </w:WordDocument> 
      </xml> 
     <![endif]--> 
     <style xmlns="" type="text/css" media="all"> 
      body {font-size: 100%;} 
      h1.normal {color: #000 !important; width: 75%;} 
      .content_block {margin-right: 3%; width: 74%;} 
      div#documentBody {margin-top: 31px;padding-bottom: 30px;} 
      div.incut-head span.incut-head-control {font-weight: bold;} 
      div.docChainList {font-family: Arial;font-size: 13px; margin: 7px 0 0; padding: 10px;} 
      table.author-tbl {width: 40%;} 
      div.page-box {width: 100%;} 
      div.page-wrapper .doc-page .content {font-size: 14px;} 
      pre {font-family: sans-serif;word-wrap: break-word;} 

      div.MsoFooter, li.MsoFooter, p.MsoFooter{ 
       margin:0in; 
       margin-bottom:.0001pt; 
       mso-pagination:widow-orphan; 
       tab-stops:center 3.0in right 6.0in; 
       font-size:12.0pt; 
      } 


      <!-- /* Style Definitions */ 
       @page Section1{ 
        size:8.5in 11.0in; 
        margin:1.0in 1.25in 1.0in 1.25in ; 
        mso-footer: f1; 
        mso-footer-margin:.5in; 
       } 

       div.Section1{ 
        page:Section1; 
       } 
      --> 
     </style> 
</head> 
<body> 
    <div class="Section1"> 
     <div xmlns="" class="content_block"> 
      <div class="above-header"></div> 
      <h1 class="normal">Header of document</h1> 
      <div id="documentBody" class="content-common"> 
       <p>Document body text.</p> 
      </div> 
     </div> 
    </div> 
    <div xmlns="" style="mso-element:footer" id="f1"> 
     <p class="MsoFooter"> 
      Copyright, 2013 
     </p> 
    </div> 
</body> 
</html> 

回答

2

有一個解決方案here。 只要注意Word HTML的寫法。 這只是我不想把它的信用(反正我改正了一些語法錯誤)......這是文字:

<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' 
xmlns='http://www.w3.org/TR/REC-html40'> 
<head> 
    <title></title> 

    <!--[if gte mso 9]> 
<xml> 
<w:WordDocument> 
<w:View>Print</w:View> 
<w:Zoom>90</w:Zoom> 
<w:DoNotOptimizeForBrowser/> 
</w:WordDocument> 
</xml> 
<![endif]--> 
    <style> 
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> 

<!-- /* Style Definitions */ 

@page Section1 
{ 
size:8.5in 11.0in; 
margin:1.0in 1.25in 1.0in 1.25in ; 
mso-header-margin:.5in; 
mso-header:h1; 
mso-footer: f1; 
mso-footer-margin:.5in; 
} 

div.Section1 
{ 
page:Section1; 
} 

table#hrdftrtbl 
{ 
margin:0in 0in 0in 9in; 
} 
--> 
</style> 
</head> 
<body lang="EN-US" style='tab-interval: .5in'> 
    <div class="Section1"> 
     <h1> 
      Time and tide wait for none</h1> 
     The quick brown fox jumps over the lazy dog ... ... 
     <table id='hrdftrtbl' border='1' cellspacing='0' cellpadding='0'> 
      <tr> 
       <td> 
        <div style='mso-element: header' id="h1"> 
         <p class="MsoHeader" style='text-align: center'>Confidential</p> 
        </div> 
       </td> 
       <td> 
        <div style='mso-element: footer' id="f1"> 
         <p class="MsoFooter"> 
          Draft <span style='mso-tab-count: 2'></span><span style='mso-field-code: "" PAGE ""'> 
          </span>of <span style='mso-field-code: "" NUMPAGES ""'></span> 
          </p> 
        </div> 
       </td></tr> 
     </table> 
    </div> 
</body> 
</html> 

正如你所看到的,它把頁眉和頁腳部分來文檔,「div class section」和「table id ='hrdftrtbl'...」之間的文本是您需要顯示的內容的HTML文本。

我唯一需要的是在頁眉/頁腳部分插入圖片的代碼。我試圖插入一個base64圖像(失敗),插入一個URL(失敗)

+1

請嘗試解釋什麼是在該鏈接。 – Jatin

+0

是的,這樣當鏈接被破壞時,我們仍然可以看到必要的信息。 –

+1

這是最好的解決方案。它不僅隱藏頁碼,而且還隱藏任何文本,例如「......的......頁......」。正如備註,使用Word 2010和2013時,只有在打印或預覽打印時纔會顯示重複的頁腳。 我試圖通過將頁腳包裝在div中或試圖用CSS來設計它,所有這些都無濟於事。經過數小時的工作,上面的表格解決方案就像一個魅力。 –