private function generatePDF($pdfData)
{
$pdf = new \TCPDF();
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Your Company');
$pdf->SetTitle('Invoice');
// Add a page
$pdf->AddPage();
$logoURL = base_url('/logo.png');
$html = '
<table width="100%" cellpadding="5">
<tr>
<td width="50%">
<img src="' . $logoURL . '" width="150" />
</td>
<td width="50%" align="right">
</td>
</tr>
</table>
<h1>Invoice #' . $pdfData['invoice_id'] . '</h1>
<p>Invoice Date: ' . $invoiceDate . '<br>
Due Date: ' . $dueDate . '</p>
<h3>Invoiced To:</h3>
<p>' . $pdfData['full_name'] . '<br>
ATTN: ' . $pdfData['phonenum'] . '<br>
' . $pdfData['country'] . '</p>
<p style="text-align:right;">PDF Generated on ' . date('l, F jS, Y') . '</p>';
$pdf->writeHTML($html, true, false, true, false, '');
return $pdf->Output('', 'S'); // 'S' returns the document as a string
}
Can anyone help me solve this problem? I'm using Codeigniter 4, and the pdf is generated but the image doesn't show that's the problem I need to solve. I tried many ways but could not solve this.
When generating the PDF the image should be displayed at the top of the pdf,
maybe use "$logoURL = base_url('/logo.png'); etc ...." in a view to see if the img src is correct?