@deron
To generate a PDF in Codeigniter, you can use a library such as DOMPDF or TCPDF.
Here is an example of how to generate a PDF using DOMPDF in Codeigniter:
1
|
$this->load->library('dompdf_gen'); |
1 2 3 4 5 6 |
$data['your_data'] = 'your data'; $html = $this->load->view('your_view', $data, true); $this->dompdf->load_html($html); $this->dompdf->render(); $this->dompdf->stream("your_pdf_filename.pdf"); |
In this example, "your_view" is the view file that contains the HTML code for the PDF, and "your_data" is the data that you want to pass to the view. The "render()" function generates the PDF, and the "stream()" function outputs the PDF to the browser.
You can also specify additional options for the PDF, such as the paper size and orientation, by using the "set_paper()" and "set_orientation()" functions.
1 2 |
$this->dompdf->set_paper('A4', 'portrait'); $this->dompdf->set_orientation('landscape'); |
I hope this helps! Let me know if you have any questions.