How to get rid of the left and top margins in css

2019-04-10 09:22发布

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.

Here's my current css.

body {
    margin: 0;
    padding: 0;
}

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

Please help.

标签: php css html2pdf
1条回答
闹够了就滚
2楼-- · 2019-04-10 09:45

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));
查看更多
登录 后发表回答