DOMPDF 无法在服务器上运行
DOMPDF not working on server
我已正确包含文件,如下所示,
require_once DIR_ROOT . '/vendor/dompdf/autoload.inc.php';
use Dompdf\Dompdf;
我正在创建教程中提到的对象
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');
这在我的本地主机上运行良好。但是创建对象失败 $dompdf = new Dompdf();在我们的服务器上。我正在使用 opencart。
在我的服务器上安装 mb_string 模块后它工作了。
纠结了一个多月终于解决了这个问题...
解决方案是
<?php
require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
?>
<html>
<head>
</head>
<body>
<h1>Sucess</h1>
</body>
</html>
<?php
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->setPaper('A4', 'portrait');
//$dompdf->setPaper('A4', 'landscape');
$dompdf->load_html($html);
$dompdf->render();
//For view
$dompdf->stream("",array("Attachment" => false));
// for download
//$dompdf->stream("sample.pdf");
?>
是的,localhost 代码在服务器上不起作用。我解决了
将 php 版本更改为 7 并进行测试。
我已正确包含文件,如下所示,
require_once DIR_ROOT . '/vendor/dompdf/autoload.inc.php';
use Dompdf\Dompdf;
我正在创建教程中提到的对象
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');
这在我的本地主机上运行良好。但是创建对象失败 $dompdf = new Dompdf();在我们的服务器上。我正在使用 opencart。
在我的服务器上安装 mb_string 模块后它工作了。
纠结了一个多月终于解决了这个问题... 解决方案是
<?php
require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
?>
<html>
<head>
</head>
<body>
<h1>Sucess</h1>
</body>
</html>
<?php
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->setPaper('A4', 'portrait');
//$dompdf->setPaper('A4', 'landscape');
$dompdf->load_html($html);
$dompdf->render();
//For view
$dompdf->stream("",array("Attachment" => false));
// for download
//$dompdf->stream("sample.pdf");
?>
是的,localhost 代码在服务器上不起作用。我解决了
将 php 版本更改为 7 并进行测试。