I am trying to send an email with 2 pdf attachments but when in the controller I call getRejectedReport method it return me error says that Call to undefined method Dompdf\FrameDecorator\Page::add_line() while the other method getReport run successfully and generate pdf that goes in email as attachment.
getting this Call to undefined method Dompdf\\FrameDecorator\\Page::add_line()
I have almost same code and same logic for both pdf blade files. here is my sample code ....
class ChecklistController extends AppBaseController
{
protected $pdf;
public function __construct(
ComplaintRepository $compRepository,
PDf $pdf,
) {
$this->compRepository = $compRepository;
$this->pdf = $pdf;
}
public function getReport($id, $type = 'stream')
{
$view = 'pdf.report';
$filePath = app()->basePath() . '/public/uploads/pdf';
$pdf = $this->pdf->loadView($view, [
'content' => $data,
])->setPaper('a4');
$pdf->setWarnings(false)->save($filePath);
}
public function getRejectedReport($id, $type = 'stream')
{
$view = 'pdf.rejected-report';
$filePath = app()->basePath() . '/public/uploads/pdf';
$pdf = $this->pdf->loadView($view, [
'content' => $data,
])->setPaper('a4');
$pdf->setWarnings(false)->save($filePath);
}
}
This is a common problem that occur when you are using the same $pdf instance for the next pdf generation.
so it is better changing your method with a fresh PDF instance see the following code
Make a new PDF instance like **$pdf = app(PDF::class); **
public function getRejectedReport($id, $type = 'stream')
{
$view = 'pdf.rejected-report';
$filePath = app()->basePath() . '/public/uploads/pdf';
// Make a fresh instance of pdf here
$pdf = app(PDF::class)->loadView($view, [
'content' => $data,
])->setPaper('a4');
$pdf->setWarnings(false)->save($filePath);
}