i have a codeigniter website where i am trying to send pdf to mail, i am trying to add this html design in pdf
Design
my pdf.php is like
<?php
require_once APPPATH . 'third_party/dompdf/autoload.inc.php';
use DompdfDompdf;
class Pdf {
protected $dompdf;
public function __construct() {
$this->dompdf = new Dompdf();
}
public function createPDF($html, $filename = '', $download = TRUE) {
$this->dompdf->loadHtml($html);
$this->dompdf->setPaper('A4', 'portrait');
$this->dompdf->render();
try {
if ($download) {
$this->dompdf->stream($filename);
} else {
return $this->dompdf->output();
}
} catch (Exception $e) {
// Handle any Dompdf exceptions here
echo 'An error occurred: ' . $e->getMessage();
}
}
}
?>
and my controller is like
public function generate_pdf() {
$this->load->library('pdf');
// Bootstrap CSS for styling
$htmlContent = $this->load->view('pdf_template', [], TRUE);
// Generate PDF
$pdfContent = $this->pdf->createPDF($htmlContent, 'sample.pdf', FALSE);
// Save PDF to file
$pdfFilePath = FCPATH . 'uploads/sample.pdf';
file_put_contents($pdfFilePath, $pdfContent);
// Send email with the PDF attachment
$this->send_email_with_attachment($pdfFilePath);
}
the issue here is, the pdf is being sent with the html content but css is not loading in that, can anyone please tell me what could be wrong in here