【发布时间】:2017-08-31 08:19:39
【问题描述】:
我已经生成了一个带有https://gist.github.com/MartinThoma/056183bc0862a787a8d4e8fe57e51f3f 的大表格的简单 HTML 页面
现在我认为标准打印选项是 300dpi,而这个 A4 页面有 2480 像素 x 3508 像素 (source)
Google Chrome PDF 打印插件在第 7 列 / 处剪切页面:
但是当我计算宽度时
var width_total = 0;
for (var i = 0; i < 15; i++) {
var theTh = $("#colTh" + i)
var thWidth = 0; // in pixel
thWidth += theTh.width();
thWidth += parseInt(theTh.css("padding-left"), 10) + parseInt(theTh.css("padding-right"), 10); //Total Padding Width
thWidth += parseInt(theTh.css("margin-left"), 10) + parseInt(theTh.css("margin-right"), 10); //Total Margin Width
thWidth += parseInt(theTh.css("borderLeftWidth"), 10) + parseInt(theTh.css("borderRightWidth"), 10); //Total Border Width
width_total += thWidth;
console.log("width " + i + ": " + width_total)
}
我在第 7 列的宽度为 1200。
我在计算可打印宽度时哪里出错了?
- 边距/边框/填充/宽度:我认为这应该是正确的
- DPI 中的页面密度:如果它介于 140 和 150 之间,则可以容纳。有没有办法找出浏览器正在使用什么/设置密度?
- 还有别的吗?
【问题讨论】:
-
pdfinfo告诉我生成的 PDF 有Page size: 595 x 842 pts (A4)。这适合 A4 尺寸 @ 72 DPI。但是它应该在 6 和 7 之间切页 ... -
有趣。即使我使用
th, td { page-break-inside:avoid; page-break-after:auto; width: 150px;max-width: 150px;min-width:150px;},Firefox 仍然适合一页上的所有列,而 chrome 会在第 7 列之后/之后插入