我有一個代碼可以使用mPDF庫生成單個PDF文件。但是,當我一次嘗試生成2個PDF文件並嘗試下載這些文件時,它不會生成第二個文件。使用mPDF生成並保存多個pdf文件
這裏是代碼:
function download($id)
{
$this->load->library('m_pdf');
// download annexC form
$this->annexc($id);
// download resident form
$this->resident($id);
}
function annexc($id)
{
$data1['udata'] = $this->general_model->getUserDetail($id);
// mprd($data);
$name1 = str_replace(' ', "-", strtolower($data1['name']));
$time1 = time();
$file_name1 = $name1.$time1.$id.'-Annexc-Form';
$html1 = $this->load->view('annexc/form_download', $data1, true);
$pdfFilePath1 = SAVE_PDF_ANNEXC.$file_name1.".pdf";
$this->m_pdf->pdf->SetDisplayMode('fullpage');
$this->m_pdf->pdf->WriteHTML($html1);
$this->m_pdf->pdf->Output(SAVE_PDF_ANNEXC.$file_name1.".pdf", "F");
}
function resident($id)
{
$data['udata'] = $this->general_model->getUserDetail($id);
$name = str_replace(' ', "-", strtolower($data['name']));
$time = time();
$file_name = $name.$time.$id.'-Residential-Form';
$html = $this->load->view('resident/form_download', $data, true);
$file_name = trim($file_name);
$pdfFilePath = SAVE_PDF_RESIDENT.$file_name.".pdf";
$this->m_pdf->pdf->SetDisplayMode('fullpage');
$this->m_pdf->pdf->defaultfooterfontstyle='';
$this->m_pdf->pdf->defaultfooterfontsize=12;
$this->m_pdf->pdf->defaultfooterline=0;
$this->m_pdf->pdf->setFooter('{PAGENO}');
$this->m_pdf->pdf->WriteHTML($html);
$this->m_pdf->pdf->Output($pdfFilePath, "F");
}
當我打電話下載(),那麼它會成功創建annexc PDF但對於第二個居民(),它會創造出具有相同annexc表單數據的PDF文件。爲什麼這樣?我應該做什麼改變?
那麼有什麼可以解決的?我應該叫它一次嗎? –