dompdf:找不到图片或类型未知 [英] dompdf : image not found or type unknown
问题描述
这是我的代码,
我主要尝试了用于在PDF上显示图像的所有方法,但仍然没有用。
您能帮我吗?
我还将DOMPDF_ENABLE_REMOTE设置为true,结果仍然相同。
Here is my code, I mostly tried all the methods for displaying image on PDF but still didnt work. Could you please help me for this. I also set DOMPDF_ENABLE_REMOTE to true and still results is same.
require_once("dompdf/autoload.inc.php");
//require('WriteHTML.php');
$html = '<body>
<div id="watermark"><img src="/var/htdocs/PDF/header.png" height="100%" width="100%"></div>
<div id="header">
<h3 style="padding-top:10px;">'.$_POST['name'].'</h3>
</div>
<div id="footer">
<h3 style="padding-top:8px; padding-right:25px;" class="CIJ">ABSOLUTE MARKET INSIGHTS</h3>
</div>
<div>
<br><br><div class="ooo" style="padding-top: 20px;">'.$_POST['comment'].'</div>
</div>
</body>';
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$canvas = $dompdf->get_canvas();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream($_POST["name"], array("Attachment" => false));
推荐答案
您应该使用完整的URL,而不是直接的URL。路径。尤其是当它不是静态图像时:dompdf将直接打开该php脚本,因此不会像执行PHP脚本那样执行它。
You should be using the full URL instead of a direct path. Especially when it is not a static image: dompdf will open that php script directly, so it won't be executed as if it's a PHP script.
如果完整的URL不起作用,您还可以显示header.php的结果是什么。要记住的一些好事情是发送适当的内容类型标题,等等。
If the full URL doesn't work, you can also show what the result of header.php is. Some good things to keep in mind are to send proper content-type headers and so on.
这篇关于dompdf:找不到图片或类型未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!