使用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));