我在代码中有一个要打印的表,它看起来像这样:
当我尝试打印表格时,它的打印格式如下所示:
我需要更改打印视图中文本的字体大小,还需要更改打印视图中的列大小。另外,如果我可以在web表格的打印视图中删除边框。
我已经使用javascript打印表。我已经利用了表ID。
<script type="text/javascript">
function PrintPage()
{
var TableToPrint = document.getElementById('thisIDisforprinting2');
newWin = window.open("");
newWin.document.write(TableToPrint.outerHTML);
newWin.print();
newWin.close();
}
</script>
发布于 2018-09-25 16:44:42
您可以使用document.write添加css标签,并使用"print“媒体查询根据需要设置表格样式。
函数PrintPage() {
var TableToPrint = document.getElementById('thisIDisforprinting2');
newWin = window.open("");
newWin.document.write(TableToPrint.outerHTML);
newWin.document.write('<style type="text/css"> @media print { #thisIDisforprinting2 { font-size: 24px; } }</style>');
newWin.print();
newWin.close();
}
在设置列的高度和删除边框的版本下面
newWin.document.write('<style type="text/css"> @media print { #thisIDisforprinting2 { font-size: 24px; border: none; } #thisIDisforprinting2 td { height: 150px; border: none; } } </style>');
发布于 2018-09-25 08:11:29
看起来您的网页使用的宽度可能超出了打印页的宽度限制。您可以尝试使用水平布局打印页面。
https://stackoverflow.com/questions/52488834
复制相似问题