PHP 7 CodeIgniter HTML2PDF.js Example to Create,Modify PDF Documents Using HTML5 & CSS3 Template in Command Line
//Load the library
$this->load->library('html2pdf');
//Set folder to save PDF to
$this->html2pdf->folder('./assets/pdfs/');
//Set the filename to save/download as
$this->html2pdf->filename('test.pdf');
//Set the paper defaults
$this->html2pdf->paper('a4', 'portrait');
//Load html view
$this->html2pdf->html(<h1>Some Title</h1><p>Some content in here</p>);
//Create the PDF
$this->html2pdf->create('save');
$data = array(
'title' => 'PDF Created',
'message' => 'Hello World!'
);
//Load html view
$this->html2pdf->html($this->load->view('pdf', $data, true));
if($path = $this->html2pdf->create('save')) {
//PDF was successfully saved or downloaded
echo 'PDF saved to: ' . $path;
}
if($path = $this->html2pdf->create('save')) {
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->subject('Email PDF Test');
$this->email->message('Testing the email a freshly created PDF');
$this->email->attach($path);
$this->email->send();
}