有没有可能用JavaScript创建一个包含两个不同方向页面(在同一个文档中)的Word文档?即第一页为纵向,第二页为横向?这正是我需要的。我已经尝试了很多方法,例如mso-break-type:section-break; mso-special-character:line-break; page-break-before:always;等等,但都没有成功。谢谢!以下是我目前的内容:
<script>
function export_to_word() {
var link, blob, url;
blob = new Blob(['\ufeff', document.getElementById("docx").innerHTML], {
type: 'application/msword'
});
url = URL.createObjectURL(blob);
link = document.createElement('A');
link.href = url;
link.download = 'Document'; // default name without extension
document.body.appendChild(link);
if (navigator.msSaveOrOpenBlob )
navigator.msSaveOrOpenBlob( blob, 'Document.doc'); // IE10-11
else link.click(); // other browsers
document.body.removeChild(link);
};
</script>
<html xmlns:office="urn:schemas-microsoft-com:office:office"
xmlns:word="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<br>
<button onclick="export_to_word()">Export</button>
<div id="docx">
<style>
@page portrait_A4_page {
size:595.45pt 841.7pt;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;
}
div.portrait_A4_page { page:portrait_A4_page; }
@page landscape_A4_page {
size:841.7pt 595.45pt;
mso-page-orientation: landscape;
margin:1.25in 1.0in 1.25in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;
}
div.landscape_A4_page { page:landscape_A4_page; }
</style>
<div class=portrait_A4_page>
<p>standard A4 portrait page information</p>
</div>
<div class=landscape_A4_page>
<table border=1>
<tr>
<td>a table that goes really wide</td>
</tr>
</table>
</div>
</div>