使用html2pdf时如何摆脱CSS的左边界和上边界 [英] How to get rid of the left and top margins in css when using html2pdf

查看:351
本文介绍了使用html2pdf时如何摆脱CSS的左边界和上边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是html2pdf,但我想使用CSS摆脱顶部和左侧的空白,但是我不能。
在输出缓冲裕量已设置为0之前,它可以在html上工作,但是当我使用 html2pdf将其转换为pdf时顶部和左边距再次出现。

I'm using html2pdf and I want to get rid of the top and left margins using css but I can't. Before output buffering margin is already set to 0, it works on html but when I convert it to pdf using html2pdf the top and left margins appears again.

这是我当前的CSS。

Here's my current css.

body {
    margin: 0;
    padding: 0;
}

#box {
    margin: 0;
    padding: 0;
    width: 803px;
    height: 1400px;
    border: 1px solid #000;
}

请帮助。

推荐答案

我怀疑页边距是由html2pdf生成的,而不是由html / css生成的。您是否尝试在 html2pdf-constructor

例如使用 array(0,0,0,0)作为最后一个参数:

I suspect that the margins are generated by html2pdf, not from the html/css. Have you tried to set the margins in the html2pdf-constructor?
E.g. with array(0, 0, 0, 0) as last parameter:

$html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8', array(0, 0, 0, 0));

这篇关于使用html2pdf时如何摆脱CSS的左边界和上边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆