1

I tried to create footer in MS Word document from this solution. It's ok, footer looks great, but text from footer duplicated in document body. How can i remove this?

Screenshot of document: http://d.pr/i/GR4U

And code of document:

<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>
4

1 回答 1

2

这里有一个解决方案。只需注意 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(失败)

于 2014-04-01T01:16:02.547 回答