How to get rid of the left and top margins in css when using html2pdf
Asked Answered
G

1

6

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.

Gravy answered 7/1, 2012 at 11:53 Comment(6)
i recommednd not using link where you ask questions:)Tantalic
@Tantalic why, what's wrong with it?Fourpence
@pekka it is really not that complicated: if you have a website that converts doc2pdf you dont ask questions(or whitout sources) about how to converting doc2pdf. Its a repuattion thingTantalic
@Tantalic what are you talking about? He is linking to the product is he is using. It's not his own site.Fourpence
@pekka: i sad "i recommend" i wasent trying to be clever :)Tantalic
@Tantalic I understand, but in this case I think it's great that he posted a link. I wish everyone did when asking questions about a product, people most often don't.Fourpence
B
18

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));
Bedrail answered 7/1, 2012 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.