【发布时间】:2021-02-05 00:49:37
【问题描述】:
我正在使用来自this topic 的代码从 HTML 创建一个 MS Word 文档。经过一些适应后,它对我来说工作正常,除了现在我在页眉和页脚see image here 的每一端都有正方形。这些方块无法手动移除,我看不出是什么在创建它们。
要重现,只需创建一个 *.doc 文件,使用 notepad++ 或 VS Code 等文本编辑器打开它,然后输入以下代码。之后用 MS Word 打开文件。
希望你们能帮我摆脱那些方块!
<html xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:w='urn:schemas-microsoft-com:office:word' xmlns:m='http://schemas.microsoft.com/office/2004/12/omml'
xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<meta charset='utf-8'/>
<title></title>
<style>
@page {
mso-page-orientation: portrait;
margin: 1cm 1cm 1cm 1cm;
}
@page Section1 {
mso-header-margin: 1cm;
mso-footer-margin: 1cm;
mso-header: h1;
mso-footer: f1;
}
div.Section1 {
page: Section1;
}
table.hdrftrtbl {
margin: 0in 0in 0in 900in;
width: 1px;
height: 1px;
overflow: hidden;
}
p.MsoHeadFoot,
li.MsoHeadFoot,
div.MsoHeadFoot,
td.MsoHeadFoot {
margin: 0;
margin-bottom:1px;
tab-stops: center 50% right 100%;
font-size: 12.0pt;
}
</style>
</head>
<body>
<br/>
TODO: Actual content goes here
<div class='Section1'>
<table class='hdrftrtbl' border='0' cellspacing='0' cellpadding='0'>
<tr>
<!-- HEADER-tags -->
<td class='MsoHeadFoot'>
<div style='mso-element:header' id='h1'>
<span style='mso-tab-count:2'>
<img src='logo.jpg' width="140" height="60">
</span>
</div>
</td>
<!-- end HEADER-tags -->
<!-- FOOTER-tags -->
<td class='MsoHeadFoot'>
<div style='mso-element:footer' id='f1'>
<span style='mso-tab-count:0'>© company name</span>
<span style='mso-tab-count:1'>TODO: beginning from page 2</span>
<span style='mso-tab-count:1'></span>
page
<span style='mso-field-code:PAGE'></span>
of
<span style='mso-field-code:NUMPAGES'></span>
</div>
</td>
<!-- end FOOTER-tags -->
</tr>
</table>
</div>
</body>
</html>
【问题讨论】: