【问题标题】:Word XML document duplicated footerWord XML 文档重复的页脚
【发布时间】:2013-05-30 08:59:18
【问题描述】:

我尝试从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>

【问题讨论】:

    标签: xml ms-word ms-office openxml


    【解决方案1】:

    有一个解决方案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(失败)

    【讨论】:

    • 请尝试解释该链接中的内容。
    • 是的,这样当链接断开时,我们仍然可以看到基本信息..
    • 这是最好的解决方案。它不仅隐藏了页码,还隐藏了诸如“Page ... of ...”之类的任何文本。作为旁注,对于 Word 2010 和 2013,重复的页脚仅在您打印或预览打印时出现。我尝试通过将页脚包装在 div 中或尝试使用 CSS 设置样式来做同样的事情,但都无济于事。经过数小时的工作,上面的桌子解决方案就像一个魅力。
    猜你喜欢
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 2015-03-19
    • 1970-01-01
    • 2013-03-09
    • 2016-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多