使用横向模式打印到硬拷贝



使用javascript以横向模式打印网页。在打印时,我想:

  1. 设置利润
  2. <
  3. 景观模式/gh>

您可以使用 @page CSS规则:

来标记打印页面的大小和边距
/* In CSS, not JavaScript */
@page {
  size: A4 landscape;
  margin: 42pt 12pt;
}
@media print {
  /* Define print-specific styles here, for example toning down the decoration
     of hyperlinks and removing the navigation. */
  a {color: inherit !important; text-decoration: none !important;}
  nav {display: none;}
}

然而,浏览器支持是参差不齐的-除了王子XML,只有IE8+和Opera支持它。如果您希望对打印进行精确的跨浏览器控制,可以考虑一种(通常是服务器端)PDF输出机制。

最新更新