Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

uddin9live's avatar

Dompdf

hi

how to set margin or a4 size paper

i want to keep zero marine.

Route::get('pdf', function () {

$mydata =  App\detailed::find(1);


$pdf = PDF::loadView('detailed-draftpdf', compact('mydata'));
return $pdf->download('invoice.pdf');

// return PDF::loadFile('http://www.github.com')->stream('github.pdf');

});

Route::get('showpdf', function () {

// return PDF::loadFile('http://www.github.com')->stream('github.pdf');

});

0 likes
1 reply
willvincent's avatar
Level 54

Page margins are specified in css for dompdf. This css rule should get you a zero margin:

@page {
  margin: 0;
}

Also, friendly tip: If you surround your code with three backticks (before and after) the syntax highlighting will work for the entire snippet.

1 like

Please or to participate in this conversation.