-
-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Description
my config file looks like this :
return [
'mode' => '',
'format' => 'A4',
'default_font_size' => '12',
// the rest of the config
];
and when i make the pdf i use this code :
use App\Models\Invoice;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
function print(){
$invoice = Invoice::first();
$data = [];
$view = 'template_1';
$pdf = LaravelMpdf::loadView($view, $data, [
'format' => ['100','500'],
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
]);
$fileName = "invoice-#{$invoice->invoice_number}.pdf";
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename={$fileName}");
return $pdf->stream($fileName);
}
the reason I am using the format ['100','500']
is to print a POS style invoice
the problem is that the the outcome page size is always 'A4' even if i clear all the cache using php artisan optimize:clear
possible workaround :
when I change the config before I load the view it works fine :
config(['pdf.format' => ['100','500']);
$pdf = LaravelMpdf::loadView($view, $data, [
'margin_left' => 0,
// the rest of the code
];
is there a better solution? or a reason why it does not take the format
value I am providing while loading the vue ?
Metadata
Metadata
Assignees
Labels
No labels