mivita/app/Libraries/CreditDetailsPDF.php
Kevin Adametz bfa3bb1df4 08 2024
2024-08-05 12:05:24 +02:00

41 lines
862 B
PHP

<?php
namespace App\Libraries;
class CreditDetailsPDF{
protected $view;
protected $pdf;
public function __construct($view)
{
$this->view = $view;
}
public function create($data, $name='test.pdf', $output='stream', $path = false){
header('Content-type: text/html; charset=UTF-8') ;//chrome
$pdf = app('dompdf.wrapper');
$pdf->getDomPDF()->set_option("enable_php", true);
$pdf->loadView($this->view, $data);
$pdf->setPaper('A4', 'portrait');
if($output === 'stream'){
return $pdf->stream($name);
}
if($output === 'download'){
return $pdf->download($name);
}
if($output === 'save'){
if($path){
$pdf->save($path.$name);
return $path.$name;
}
}
}
}
?>