You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将宽幅HTML页面打印时拆分为两页

问题

我有一个宽度为42cm(A4宽度的两倍)的HTML页面,打印时内容会被裁切。我需要将它打印成两页用作相册:

  • 第一页显示原页面的左半部分
  • 第二页显示原页面的右半部分

计划通过Puppeteer、Unoconv或Gotenberg实现该功能,当前使用的HTML代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <style>
        @media print {
            body {
                padding: 0;
                margin: 0;
            }
        }

        .template {
            width: 42cm;
        }

        .image {
            border: 1px solid;
            width: 100%;
            background: #c0c0c0;
            padding: 10cm;
            text-align: center;
            font-size: 100pt;
            text-transform: uppercase;
        }
    </style>
    <title>Test print</title>
</head>
<body>
<div class="template">
    <div class="image">
        wide block
    </div>
</div>
</body>
</html>

内容的提问来源于stack exchange,提问作者Petro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 17:52:11