【问题标题】:Html table won't print full widthHtml 表格不会打印全宽
【发布时间】:2019-05-02 05:14:50
【问题描述】:

帮助,尝试使用 html 表格打印日历,在 Mac 上打印正常,但 Windows,所有浏览器,无论 CSS 打印设置如何,它都会在顶部放置 3" 边距。客户希望日历打印全出血。我可以如果我将浏览器上的打印设置调整为不缩小以适合然后将其设置为 110%,则让它打印全尺寸,但该解决方案会弄乱类型并与日历中的字符混淆。有什么办法吗它使用直接的 CSS 吗?

【问题讨论】:

  • 你试过@page { size: auto;边距:0mm; } ?
  • 是的,我已经尝试过了,并且尝试了不同的边距设置、页面大小,我可以让它看起来更糟但永远不会更好。谢谢!
  • 你能分享你的html吗
  • 嗨迪帕克!我受 NDA 约束,无法共享 html。希望得到答案而不必透露。谢谢!
  • 你能试试width: 100%;

标签: html css printing html-table


【解决方案1】:

添加这个简单的 Javascript 代码来打印日历

<script language="javascript">
function Clickheretoprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=400, height=400, left=100, top=25"; 
  var content_vlue = document.getElementById("print_content").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>Print</title>'); 
   docprint.document.write('</head><body onLoad="self.print()" style="width: 800px; font-size:12px; font-family:arial;">');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}
</script>
<a href="javascript:Clickheretoprint()">Print</a>
<div id="print_content" style="width: 100%;">
Calendar/html table goes here
</div>

【讨论】:

  • 您好,打印没有问题,正在打印。困难在于使日历具有完整的高度和宽度。谢谢!
  • 我很想看看 HTML 代码,但你说你受 NDA 约束。我真的无能为力。
猜你喜欢
  • 2021-11-24
  • 1970-01-01
  • 1970-01-01
  • 2019-05-20
  • 1970-01-01
  • 2012-02-12
  • 1970-01-01
  • 1970-01-01
  • 2016-11-22
相关资源
最近更新 更多