admin管理员组文章数量:1399127
This is how it looks my HTML:
In order to print the page I am using in JavaScript the window.print()
function.
$scope.print= function() {
$("#tab2-panel-tools").hide();
$("#title-row").hide();
window.print();
$("#tab2-panel-tools").show();
$("#title-row").show();
}
In the next image is my print preview. In the print preview the table exceed the width of the page. How can I fit the table in the page?
This is how it looks my HTML:
In order to print the page I am using in JavaScript the window.print()
function.
$scope.print= function() {
$("#tab2-panel-tools").hide();
$("#title-row").hide();
window.print();
$("#tab2-panel-tools").show();
$("#title-row").show();
}
In the next image is my print preview. In the print preview the table exceed the width of the page. How can I fit the table in the page?
Share Improve this question edited Jan 30, 2018 at 10:48 Roland Rácz 2,9993 gold badges20 silver badges46 bronze badges asked Jan 26, 2018 at 13:29 Wekerle TiborWekerle Tibor 4772 gold badges7 silver badges19 bronze badges 4- Make a pdf in landscape – mplungjan Commented Jan 26, 2018 at 13:30
- Make it smaller? – Liam Commented Jan 26, 2018 at 13:31
- How can I make it smaller only in the print preview? – Wekerle Tibor Commented Jan 26, 2018 at 13:33
-
Change the
scale
in settings (clickmore settings
on the left) to print it smaller. Would be better inlandscape
-- change it in settings too. – ild flue Commented Jan 26, 2018 at 13:36
2 Answers
Reset to default 4You can solve it with css, to set a new style for your printed versions, use media print
@media print {
table{
font-size: 10px;//customize your table so they can fit
}
}
I found a solution, using javascript, here is my code:
$scope.print= function() {
var nrColumns = $("#reportPrintPreviewTableBody tr:first td").length;
//here I can put as many "if"-s as I need
if (nrColumns >= 14) {
$("#reportPrintPreviewTable").css("font-size", "10px");
}else if (nrColumns >= 10) {
$("#reportPrintPreviewTable").css("font-size", "14px");
}
//$("#reportPrintPreviewTable").css("height", "100%");
$("#tab2-panel-tools").hide();
$("#title-row").hide();
window.print();
$("#reportPrintPreviewTable").css("font-size", "11px");
$("#tab2-panel-tools").show();
$("#title-row").show();
}
本文标签: javascriptwindowprint() set a table fit in pageStack Overflow
版权声明:本文标题:javascript - window.print() set a table fit in page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744171049a2593781.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论