dompdf HTML to PDF - can't set margin of page

I figured out that neither body or @page works in this version of dompdf.

the problem was in the main CSS, where I put every tyme this line:

*{margin:0;padding:0}

I find out that margins of the PDF are decided in base of the margin of the HTML, so I removed that line with the global selector and replaced with:

th,td,p,div,b ... {margin:0;padding:0}
html{margin:40px 50px}

This works as "un-expected" and I get the right margin in every page.

NOW I'M HAPPY. I really don't know who down-vote my question, I think it's very important! In fact everywhere in internet there's the wrong answer (using body or @page margin).

solution: use in CSS html{margin:...}


This fixed my problem:

        @page {
            margin: 0px 0px 0px 0px !important;
            padding: 0px 0px 0px 0px !important;
        }