php – 在DOMpdf目录之外用DOM PDF创建pdf

嗨,我的网站上安装了mybb.我还安装了dompdf,它在自己的目录中工作,即我已安装在“DOM”目录中.现在我可以使用这个简单的代码轻松地通用pdf,保留在“DOM”目录中.

<?PHP
require_once "dompdf_config.inc.PHP";
//$file = "www/test/css_at_font_face.html"; 
$file="msf.html";
$dompdf = new DOMPDF();
$dompdf->load_html_file($file);
$dompdf->render();
$dompdf->stream("sample.pdf");

?>

如果我尝试访问导演DOM之外的其他文件,即

load_html_file($文件);
$dompdf-&GT渲染();
$dompdf-&GT流( “sample.pdf”);

?&GT
我收到错误请求的远程文件,但DOMPDF_ENABLE_REMOTE为false

解决方法:

要在不启用远程文件访问的情况下加载html:

<?PHP
require_once "dompdf_config.inc.PHP";
$file = "www/test/css_at_font_face.html"; 
$html=file_get_contents($file);
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");

?>

要启用远程文件访问:

取自dompdf_config.inc.PHP

/**
 * Enable remote file access
 *
 * If this setting is set to true, DOMPDF will access remote sites for
 * images and CSS files as required.
 * This is required for part of test case www/test/image_variants.html through www/examples.PHP
 *
 * Attention!
 * **This can be a security risk**, in particular in combination with DOMPDF_ENABLE_PHP and
 * allowing remote access to dompdf.PHP or on allowing remote html code to be passed to
 * $dompdf = new DOMPDF(); $dompdf->load_html(...);
 * This allows anonymous users to download legally doubtful internet content which on
 * tracing back appears to being downloaded by your server, or allows malicIoUs PHP code
 * in remote html pages to be executed by your server with your account privileges.
 *
 * @var bool
 */
def("DOMPDF_ENABLE_REMOTE", true);

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...