Note: mpdf 6.0
Greetings,
In my efforts to produce precise PDFs using mpdf for future printing purposes, I have encountered an issue with the positioning of elements on the page. I require these elements to be positioned precisely from the top left corner without any implicit margins or paddings that could disrupt their placement.
Issue: It seems that mpdf is not adhering to the CSS rules and constructor values set for margins and padding in the document root. The body in the PDF appears to have unwanted margins, which creates a problem when trying to position child elements accurately. Strangely, the same HTML and stylesheet combination renders correctly in a web browser.
$mpdf = new Mpdf([
//'debug' => true,
'format' => 'A4',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0
]);
I have tried setting margins and paddings to 0 wherever possible, including:
body {
margin: 0mm;
padding: 0mm;
}
I am unsure of where the problem lies. Any advice on how I can resolve this issue would be greatly appreciated.