-1

i want to generate a pdf file in code igniter, i have used CI db utilities to get data from db in csv format

my model is this..

 function prr(){
        $id=$this->db->insert_id();
        $query = $this->db->query("SELECT * FROM bookings where did='1' && email='jk@gmail.com' && id='$id'");
        $result2=$this->dbutil->csv_from_result($query); 
        return $result2;
    }    

i am getting a result like this.. but know how to print it in pdf??

"id","did","email","mobile","slot","disease","age","gender","date", "18","1","jk@gmail.com","8528263923","morning-to-noon"," bjlk","bk","male","28-04-2016", 
NEET JASSI
  • 85
  • 1
  • 3
  • 12

1 Answers1

0
function prr(){
    $id=$this->db->insert_id();
    $query = $this->db->query("SELECT * FROM bookings where did='1' && email='jk@gmail.com' && id='$id' ");
    $result = $query->result_array();

    $pdfFilePath = FCPATH."/downloads/reports/query.pdf";

    ini_set('memory_limit','32M'); // boost the memory limit if it's low <img class="emoji" draggable="false" alt="" src="https://s.w.org/images/core/emoji/72x72/1f609.png">

    $this->load->library('pdf');
    $pdf = $this->pdf->load();
    $pdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822)); // Add a footer for good measure <img class="emoji" draggable="false" alt="" src="https://s.w.org/images/core/emoji/72x72/1f609.png">
    $pdf->WriteHTML($result); // write the HTML into the PDF
    $pdf->Output($pdfFilePath, 'F'); // save to file because we can
}

Using mpdf with codeigniter

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85