当在fpdf/fpdfi中使用现有模板时,只显示文件的大小


when using existing template in fpdf/fpdfi displays only the size of the file

如何在fpdf中使用现有模板。我已经使用了fpdi,可以生成pdf,但问题是,它没有使用源文件。它只显示文件的大小和我添加的附加文本。下面是我试过的代码:

public function template_trial(){
$this->load->library('fpdf'); 
$this->load->library('fpdi'); 
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("test.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
// now write some text above the imported page
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');
$pdf->Output('tes.pdf','D');
}

示例文本in pdf:

这个PDF的文件大小只有12kb。这只是一个简单的文本

$mpdf = new mPDF('c','A4','','',11,10,20,10,10,10);
$mpdf->SetImportUse();
$mpdf->SetDocTemplate('layout_bb.compressed.pdf',true); // Add Template
$mpdf->AddPage();
$mpdf->allow_charset_conversion = true;
$mpdf->charset_in = 'utf-8';
$mpdf->WriteHTML($html); // Put my content on page
$mpdf->Output();