我正在尝试从 HTML 文档创建 PDF 文档。我正在使用 DOMPDF 来执行此操作,因为我发现其他所有文档要么太复杂,要么需要我在 Web 服务器本身安装一些东西。我只需要一个非常简单的 HTML 到 PDF 并强制下载某种脚本。到目前为止,这是我的代码。
它几乎完全可以工作。唯一不起作用的是图像......出于某种原因......当我回显 $html 变量并将其加载到它自己的页面中时它会起作用。
PHP
include('dompdf/dompdf_config.inc.php');
$html = $html_header . formatFormResultDownload($userid) . $html_footer;
$dompdf = new DOMPDF();
$dompdf->set_paper("a4");
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream('User Gallery (' . date('Y-m-d H:i:s') . ').pdf');
HTML
<!DOCTYPE html>
<html>
<head>
<title>****</title>
</head>
<body>
<table border="1" cellpadding="10" width="100%">
<tr>
<td width="50%"><img src=
"http://****.net/client/****/images/logo-large.gif"></td>
<td width="50%"><span><strong>Email</strong>:
****@****.net</span><br>
<span><strong>Company Name</strong>:****</span><br>
<span><strong>Company Email</strong>:****</span></td>
</tr>
</table>
<table border="1" cellpadding="10" width="100%">
<tr>
<td align="center" width="25%"><span><img src=
"http://****.net/client/****/index.php?option=com_datsogallery&view=sbox&catid=7&id=70635"
style="width:200px" width="100%"></span><br>
<br>
<span><strong>IS Reference</strong>: 70635</span><br>
<span><strong>Author</strong>: Rob Speakman</span><br></td>
<td align="center" width="25%"><span><img src=
"http://****.net/client/****/index.php?option=com_datsogallery&view=sbox&catid=7&id=71173"
style="width:200px" width="100%"></span><br>
<br>
<span><strong>IS Reference</strong>: 71173</span><br>
<span><strong>Author</strong>: James Hearne</span><br></td>
<td align="center" width="25%"><span><img src=
"http://****.net/client/****/index.php?option=com_datsogallery&view=sbox&catid=7&id=71177"
style="width:200px" width="100%"></span><br>
<br>
<span><strong>IS Reference</strong>: 71177</span><br>
<span><strong>Author</strong>: James Hearne</span><br></td>
<td align="center" width="25%"><span><img src=
"http://****.net/client/****/index.php?option=com_datsogallery&view=sbox&catid=7&id=71171"
style="width:200px" width="100%"></span><br>
<br>
<span><strong>IS Reference</strong>: 71171</span><br>
<span><strong>Author</strong>: Makiko</span><br></td>
</tr>
</table>
</body>
</html>
PDF格式
谢谢