问题
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.
回答1:
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));
来源:https://stackoverflow.com/questions/8769474/how-to-get-rid-of-the-left-and-top-margins-in-css-when-using-html2pdf