Vikash Kumar
Vikash Kumar

Reputation: 41

mPDF - How to create multiple PDFs?

I have two functions. 1st for creating a Debit Note and 2nd for creating Invoice. I call Debit Note Function first and then Invoice function. The content of both files appears to be Debit Note. However the file names seems to be correct for both the files.

When I call Invoice function 1st and then Debit Note function. The content of both the files appears to be Invoice and the file names seems to be correct for both the file.

PS: I am calling both the functions together.

$this->mpdf->setAutoTopMargin = 'stretch';
$this->mpdf->setAutoBottomMargin = 'stretch';
$this->mpdf->SetHTMLHeader($this->pdftemplate->Header());
$this->mpdf->SetHTMLFooter($this->pdftemplate->Footer());
$html = $this->pdftemplate->debitNote($debitNoteNo, $narration, $amount);
$this->mpdf->SetTitle("Debit Note");
$this->mpdf->SetAuthor("Vikash");
$this->mpdf->SetCreator("Vikash");
$this->mpdf->SetSubject($debitNoteNo);
$this->mpdf->WriteHTML($html);
$url = "/temp/dn/" . $debitNoteNo . ".pdf";
$this->mpdf->Output($url, "F");




$this->mpdf->setAutoTopMargin = 'stretch';
$this->mpdf->setAutoBottomMargin = 'stretch';
$this->mpdf->SetHTMLHeader($this->pdftemplate->Header());
$this->mpdf->SetHTMLFooter($this->pdftemplate->Footer());
$html = $this->pdftemplate->invoice($invoiceNo, $narration, $amount);
$this->mpdf->SetTitle("Invoice");
$this->mpdf->SetAuthor("Vikash");
$this->mpdf->SetCreator("Vikash");
$this->mpdf->SetSubject($invoiceNo);
$this->mpdf->WriteHTML($html);
$url = "/temp/invoice/" . $invoiceNo . ".pdf";
$this->mpdf->Output($url, "F");

Can anyone help me with this? Thanks for reading the question and your valuable answers.

Upvotes: 1

Views: 2873

Answers (1)

Finwe
Finwe

Reputation: 6725

As I have noted in the issue at github, the safest way is to create a separate mPDF instance for each generated file.

Upvotes: 2

Related Questions