@lottie
To use TCPDF in Codeigniter, you can follow these steps:
- Download and extract the TCPDF library from the official website (https://www.tcpdf.org/).
- Place the extracted TCPDF folder inside the application/libraries folder of your Codeigniter project.
- In your controller, load the TCPDF library using the $this->load->library() method. For example:
1
|
$this->load->library('tcpdf');
|
- Create a new PDF document using the TCPDF() constructor. You can pass the page size, orientation and other parameters as arguments to the constructor. For example:
1
|
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
|
- Set the document properties using the SetTitle(), SetAuthor() and SetSubject() methods. For example:
1
2
3
|
$pdf->SetTitle('My PDF Document');
$pdf->SetAuthor('John Doe');
$pdf->SetSubject('PDF with TCPDF in Codeigniter');
|
- Add content to the PDF using the various methods provided by TCPDF, such as AddPage(), WriteHTML(), Cell(), Multicell(), etc.
- Output the PDF to the browser or save it to a file using the Output() method. For example:
1
|
$pdf->Output('my_pdf_document.pdf', 'I');
|
This will output the PDF to the browser. You can also use the F
option to save the PDF to a file on the server.
I hope this helps! Let me know if you have any questions.