Reputation: 2103
I have a table contains multiple rows and each row has an image.
<table>
<tr>
<td style="">
<img src="<?php echo $img_path; ?>" />
<?php echo ucwords($name); ?>
</td>
<td style="">
<span style="border-bottom: 1px solid;margin-left: 98px;">
<?php echo $date; ?></span>
</td>
</tr>
<tr>
<td>
<?php echo $role; ?>
Signature
</td>
<td style="">
Date
</td>
</tr>
</table>
Is it possible in HTML2PDF to show images as shown in html rather than using his built in functions?
Upvotes: 0
Views: 10105
Reputation: 3950
<?php
require('html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();
$fp = fopen("sample.html","r");
$strContent = fread($fp, filesize("sample.html"));
fclose($fp);
$pdf->WriteHTML($strContent);
$pdf->Output("sample.pdf");
echo "PDF file is generated successfully!";
?>
Alternatively, you may use TCPDF and can try like this
$content='<img src="sample.jpg">';
$html = <<<EOD
$content
EOD;
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$pdf->Output("sample.pdf", 'F');
Upvotes: 5