【发布时间】:2018-07-25 13:04:34
【问题描述】:
我需要你的帮助。我有一个表单,它有 2 个并排的 div(左右),作为 2 列。
<div class="row">
<div class="col-lg-12" id="printable">
<div class="col-lg-6">
<form role="form"></form>
</div>
<div class="col-lg-6">
<form role="form"></form>
</div>
</div>
</div>
我有两个 javascript 来打印那些 div
<script type="text/javascript">
function printDiv_1(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
function PrintDiv_2() {
var divContents = document.getElementById("printdivcontent").innerHTML;
var printWindow = window.open('', '', 'height=200,width=400');
printWindow.document.write('<html><head><title>Print DIV Content</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
}
但结果在 pdf 文件中 格式总是按页面从上到下顺序排列。它变成了 2 行。
如何克服这个问题? 我想,我想念 javascript 中的某些内容。
感谢您的建议。
【问题讨论】:
标签: javascript html twitter-bootstrap printing