Converting HTML to PDF we are using Dompdf library. You can download it from here and paste it into application\libraries folder
1. Create pdf.php file and paste below code into it.
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once 'dompdf/autoload.inc.php'; use Dompdf\Dompdf; class Pdf extends Dompdf { public function __construct() { parent::__construct(); } } ?>
2. Use below code into controller file.
$this->load->view('welcome_message'); // Load a view
$html = $this->output->get_output();
// Load pdf library
$this->load->library('pdf');
$this->pdf->loadHtml($html);
$this->pdf->setPaper('A4', 'landscape');
$this->pdf->render();
// Output the generated PDF (1 = download and 0 = preview)
$this->pdf->stream("html_contents.pdf", array("Attachment"=> 0));
Ref URL: https://www.webslesson.info/2018/04/codeigniter-pdf-generation-using-dompdf.html

