加一个style标签,里面设置@page的上下边框为0mm左右为auto,这里就是设置纸张的上下边距为0mm,代码如下:

<style>
    @page {
        size: auto; /* auto is the initial value */
        margin: 0mm auto 0mm auto; /* this affects the margin in the printer settings */
    }
</style>

部分语言直接写@page会报错,需要写成“@@page”