You can see many articles and blogs on Dompdf in CodeIgniter 4, but they are composer base installations.
Here we will see, how we can use Dompdf in CodeIgniter 4 manually, without using the composer.
STEP 1:
Download the vendor folder, and extract it on the root.
‘vendor’ folder is the folder created when we use the composer.
STEP 2:
Load Dompdf on top of controller
1 | use Dompdf\Dompdf; |
STEP 3:
Create html_to_pdf method in controller.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function html_to_pdf(){ $dompdf = new Dompdf(); $data = [ 'name' => 'John Doe', 'address' => 'USA', 'mobileNumber' => '000000000', 'email' => 'john.doe@email.com' ]; $html = view('welcome_message', $data); $dompdf->loadHtml($html); $dompdf->render(); $dompdf->stream('resume.pdf', [ 'Attachment' => false ]); exit(); } |