2016-06-14 98 views
1

我試圖在循環中生成pdfs成員id,但每次我只有第一個,我在foreach中添加代碼,所以它運行多次,但它只給我一個pdf.please誰來幫幫我。codeigniter生成多個pdf

public function pdf($ids){ 

    $k = 0; 
    foreach ($ids as $key => $id) { 


    $data[$k]['academics'] = $this->Utility_model->get_all_from_table_where('member_academics', array('member_id' => $id)); 
    $data[$k]['member_employment'] = $this->Utility_model->get_all_from_table_where('member_employment', array('member_id' => $id)); 
    $data[$k]['member_data'] = $this->Utility_model->get_all_from_table_where('members',array('member_id' => $id)); 
    $data[$k]['disclosure'] = $this->Utility_model->get_all_from_table('generalsettings',array('key'=>'disclosure')); 
    $data[$k]['enrollment_fee'] = $this->Utility_model->get_all_from_table('member_invoices',array('user_id' => $id,'paymentFor'=>'Enrollment Fee')); 
    $data[$k]['enrollment_fee']['payment'] = $this->Utility_model->get_all_from_table('member_payments',array('invoice_id'=>$data[$k]['enrollment_fee']['id'])); 

    $j=0; 
    if (!empty($data[$k]['member_data'])) { 
     foreach ($data[$k]['member_data'] as $member) { 
      $data[$k]['member_data'][$j]['term'] = $this->Utility_model->get_all_from_table('term', array('term_id' => $member['term_id'])); 
      $data[$k]['member_data'][$j]['degree'] = $this->Utility_model->get_all_from_table('degree', array('degree_id' => $member['degree_id'])); 
      $data[$k]['member_data'][$j]['year'] = $this->Utility_model->get_all_from_table('year', array('year_id' => $member['year_id'])); 
      $data[$k]['member_data'][$j]['address'] = $this->Utility_model->get_all_from_table('member_addresses', array('id' => $member['address_id'])); 

      $j++; 
     } 
    } 

    $this->load->view('admin/reports_management/applications_pdf/pdf_output',$data[$k],false); 
    $html = $this->output->get_output(); 

    $this->load->library('dompdf_gen'); 
    $this->dompdf->load_html($html); 
    $this->dompdf->render(); 
    $this->dompdf->stream($k."file".".pdf"); 
    $k++; 
    } 
    // echo "<pre>"; 
    // print_r($data); 
    // die; 
} 
+0

我不太明白你想要做的事情。你想在單個頁面上顯示多個pdf嗎? – Efekan

回答

0

只要您只請求頁面,您就無法獲得控制器方法輸出多個文件。您可以嘗試使用多頁PDF,或者需要更改控制器的調用方式,並多次調用它。

看到這個答案,查看有關多頁PDF輸入信息:How to create several pages with dompdf