Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未在dompdf中渲染图像_Php_Codeigniter_Dompdf - Fatal编程技术网

Php 未在dompdf中渲染图像

Php 未在dompdf中渲染图像,php,codeigniter,dompdf,Php,Codeigniter,Dompdf,我正在使用codeIgniter和dompdf为我的应用程序生成PDF。下面的代码是我用来显示图像的代码 <div class=\"block_head\"> <h2>Image display</h2>"; $image_location = "/images/xxx.png"; $html .="<img src=\"".$image_location."\" width=\"200\" height=\"200\" /

我正在使用codeIgniter和dompdf为我的应用程序生成PDF。下面的代码是我用来显示图像的代码

<div class=\"block_head\">
     <h2>Image display</h2>";
     $image_location = "/images/xxx.png";
     $html .="<img src=\"".$image_location."\" width=\"200\" height=\"200\" />
</div>";

图像显示”;
$image_location=“/images/xxx.png”;
$html.=”
";
我测试并调试了所有方法,以确定我是否做错了什么。像这样,我首先检查路径是否错误。这是服务器上的路径。它是正确的。我通过回显$html进行了测试,它也显示了完美的路径。当我单击该路径时,图像正在显示。但当我尝试以pdf格式呈现它时,它不会显示

注意:PDF完全没有图像生成。

请尝试以下操作

如果要为图像提供完整URI,则将其视为外部的, 因此,定义的costant DOMPF\u ENABLE\u REMOTE必须设置为true


您是否使用
$dompd->load_html($html);
将此文档加载到dompd?如果是这样,则可能会遇到上下文问题。当您以这种方式加载文档时,dompd不知道文档的基本路径。因此,它假定您是从本地文件系统工作的。在此上下文中,根路径为“/“转换为本地文件系统的根,而不是web内容目录的根。使用与实现dompdf的PHP文件相关的路径,或者指定当前文件系统中的完整路径。

其余代码在哪里?你已经把PHP和HTML混在一起了,这是保密的,代码中没有错误。这是我用来显示图像的代码块好的,我会给你我的答案,但这也是机密;)我的意思是,你是不是在唱那首歌?因为如果你是,你做得不对。还是将其设置为变量?发生了什么事?我想在DOMPF中我们不需要回应任何东西。当我们尝试使用$dompdf->load\uHTML($html)呈现$html字符串时;它会自动显示图像和任何html数据。啊,我现在明白了。您需要操作pdf对象,如
$pdf->image($path,$w,$y,$img\u w,$img\u h),启用远程,使用完整路径,启用php?