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
}
谁能帮我解决这个问题吗?我正在使用 Codeigniter 4,并且生成了 pdf,但图像没有显示这是我需要解决的问题。我尝试了很多方法但无法解决这个问题。
生成 PDF 时,图像应显示在 pdf 的顶部,
也许可以在视图中使用“$logoURL = base_url('/logo.png');等等....”来查看img src是否正确?