Word XML文档重复页脚

时间:2013-05-30 08:59:18

标签: xml ms-word ms-office openxml

我尝试在this solution的MS Word文档中创建页脚。 没关系,页脚看起来很棒,但是来自页脚的文本在文档正文中重复。 我怎么能删除这个?

文档截图: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>

1 个答案:

答案 0 :(得分: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图像(FAIL),以插入URL(FAIL)