Mpdf use pdf template to create new pdf document

Viewed 1933

How to use "sample.pdf" as template to create new pdf document with Mpdf?

We have one page pdf template with large number of placeholders and we want to populate them.

We start learning with trying to generate copy of template without any data.

    $this->mpdf = new Mpdf(); 

    $this->mpdf->SetDisplayMode('fullpage');
    $this->mpdf->SetCompression(false);
    $this->mpdf->SetSourceFile(APP . 'Template' . DS . 'Pdf' . DS . 'sample.pdf');
    $tpl = $this->mpdf->ImportPage(1); // *
    $this->mpdf->AddPage(); // *
    $this->mpdf->useTemplate($tpl); // *

    $this->mpdf->Output(TMP . 'test.pdf');

But "test.pdf" is blank.

Update:

Our sample.pdf has 911KB size, our test.pdf 1KB, but when comment lines // * our test.pdf have same size as sample.pdf but doc is blank / white page.

UPDATE with working code we have read other tuts.

    $this->mpdf->SetImportUse();
    $this->mpdf->SetDocTemplate(APP . 'Template' . DS . 'Pdf' . DS . 'sample.pdf', true);
    $this->mpdf->AddPage();

    $this->mpdf->Output(TMP . 'testpdf.pdf');
0 Answers
Related