繁体   English   中英

domPDF背景图像未在PDF中呈现

[英]domPDF background image is not rendering in the PDF

<?php

include('../helper/app2.php');

$admin = new admin;

$preview = $admin->pdfPreview();

$html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title> New Document </title><meta name="Generator" content="EditPlus"><meta name="Author" content=""><meta name="Keywords" content="">  <meta name="Description" content="">  <link href="../../css/style.css" rel="stylesheet" type="text/css" /></head><body><div class="biegeBox"><div class="cardContainer"><div class="cardImg" style="background-image:url(http://'.$_SERVER['SERVER_NAME'].'/demo/'. $preview[0]['image'].'); background-repeat:no-repeat;"><div class="cardQuote">'.$preview[0]['desc'].'</div></div></div></div></body></html>';

if ( isset( $html ) ) {

    require_once("dompdf_config.inc.php");

    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper($_POST["paper"], $_POST["orientation"]);
    $dompdf->render();

    $dompdf->stream("dompdf_out.pdf", array("Attachment" => false));

    exit(0);
}
?>

我用来从dom创建pdf的上述代码,但未在pdf中渲染图像。 谁能帮我解决这个问题。 阅读此DOMPDF页面背景(或替代方法?)问答之后,我更改了background属性。

这可能并不完全适用于您,但是在我的共享托管环境中,我能够包含图像的唯一方法是将图像与HTML文件放在同一目录中,并通过其相对路径进行引用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM