Reputation: 49
I am using mpdf library in PHP to create a pdf file from HTML. I need to set the page mode in Custom mode
Upvotes: 2
Views: 24716
Reputation: 904
I wanted to reduce the edge of the barcodes a bit. This code helped
$mpdf = new Mpdf([
"tempDir" => public_path("tmp"),
"mode" => "utf-8",
"margin_left" => 5,
"margin_right" => 5,
"margin_top" => 5,
"margin_bottom" => 5,
"margin_header" => 5,
"margin_footer" => 5,
]);
See Mpdf.php
private function initConstructorParams(array $config)
{
$constructor = [
'mode' => '',
'format' => 'A4',
'default_font_size' => 0,
'default_font' => '',
'margin_left' => 15,
'margin_right' => 15,
'margin_top' => 16,
'margin_bottom' => 16,
'margin_header' => 9,
'margin_footer' => 9,
'orientation' => 'P',
];
foreach ($constructor as $key => $val) {
if (isset($config[$key])) {
$constructor[$key] = $config[$key];
}
}
return array_values($constructor);
}
Upvotes: 0
Reputation: 994
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4']);
you can change your file size using these code lines (A4/A3/A2....) when declaring the mpdf class. for more information click here
Upvotes: 3
Reputation: 6725
[mPDF 7.x] See format
parameter and Example #2 on mPDF __construct documentation page:
// Define a page size/format by array - page will be 190mm wide x 236mm height
$mpdf = new \Mpdf\Mpdf(['format' => [190, 236]]);
The format is an array of width and height in millimeters.
Upvotes: 9
Reputation: 2425
Please see this example code -
$mpdf=new mPDF('utf-8', array(190,236)); // Define a page size/format by array - page will be 190mm wide x 236mm height
add options like this:
$mpdf = new mPDF('', // mode - default ''
'', // format - A4, for example, default ''
0, // font size - default 0
'', // default font family
15, // margin_left
15, // margin right
16, // margin top
16, // margin bottom
9, // margin header
9, // margin footer
'L'); // L - landscape, P - portrait
Upvotes: 0