html - 如何在同一张 A4 纸上打印两次网页?
问题描述
我想要在同一张 A4 纸上打印两份发票。反正有没有达到同样的效果?保证发票的单张打印(在我的例子中是 html 表格)不会超过 A4 纸的一半。
解决方案
如果我正确理解了您的问题,您将在 A4 页面上打印 2 张发票的 .html 文件首先需要准备为 .html/.php 文件(网页)然后打印。
我还将假设,您已经创建了一个将数据提取到发票中的动态页面。
/** style.css **/
.invoice {
margin-top: 2em;
}
span {
color: blue;
border: 1px solid black;
}
.extra span {
color: inherit;
}
@media print {
body{
width: 21cm;
height: 29.7cm;
margin: 20mm; /* Adjust margin as you like. */
}
* {background: transparent !important; color: black !important; text-shadow: none !important; filter:none !important; -ms-filter: none !important} /* Black prints faster */
pre, blockquote {border: 1px solid #999; page-break-inside: avoid; }
thead {display: table-header-group; } /* Repeat header row at top of each printed page */
tr, img {page-break-inside: avoid; }
img {max-width: 100% !important; }
@page {margin: 0.5cm}
p, h2, h3 {orphans: 3; widows: 3}
h2, h3{page-break-after: avoid}
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="invoice">
Here is <span>First invoice table format</span>
</div>
<div class="invoice extra" style="color:green">
Here is <span>Second invoice table format</span>.
</div>
</body>
</html>
推荐阅读
- angular - Angular 8 Resolver - 如何从一个解析器获取数据作为其他解析器的输入?
- python - 对 hex 与 utf-8 编码感到困惑
- python - 使用请求从网页保存图像
- regex - 正则表达式删除第一个空行
- java - 无法使用 POSTMAN 删除(映射)我的数据库的对象
- amazon-web-services - “s3cmd get”仅用于更改的文件
- react-native - 执行 UI 块时引发异常:“parentNode”是必需的必需参数
- php - 我想在 jquery 克隆表行后清除字段
- android - 如何从片段内部调用父活动的方法
- javascript - Firefox 扩展:打开窗口并写入动态内容