Vijayanand Premnath
Vijayanand Premnath

Reputation: 3605

Laravel multiple PDF generation

I am using Laravel-pdf package package to generate pdf. I want to generating two pdfs with different contents. But this package does not allow me to create second pdf with different content. I am getting first content in the second pdf.

This is my code

$pdf = PDF::loadView('pdf.bill', $data);
return $pdf->save('invoice.pdf'); 

$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->save('agreement.pdf'); 

Upvotes: 1

Views: 894

Answers (1)

Vijayanand Premnath
Vijayanand Premnath

Reputation: 3605

I have solved the issue by changing PDFWrapper class's save method as below

public function save($filename) {
$mpdf=new \mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); 
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;  // 1 or 0 - whether to indent the first level of a list
$mpdf->WriteHTML($this->html);    
return $mpdf->Output($filename, 'F');
}

Upvotes: 1

Related Questions