【问题标题】:Dompdf Class 'Dompdf\Dompdf' not found未找到 Dompdf 类“Dompdf\Dompdf”
【发布时间】:2021-03-12 11:21:17
【问题描述】:

使用 Dompdf 生成 pdf 文件。该文件已成功创建并下载,但我正在运行它的页面会生成一个致命错误 - 找不到类“Dompdf\Dompdf”。

我已经下载了最新的包并上传到服务器。

我正在使用此处的快速启动代码 - https://github.com/dompdf/dompdf#easy-installation

require_once 'path/to/the/folder/here/dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;

// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$dompdf->stream();

我已经阅读了我能找到的所有相关支持帖子,但似乎没有任何效果

【问题讨论】:

    标签: dompdf


    【解决方案1】:

    试试这个

    <?php
    namespace Dompdf;
    require_once 'dompdf/autoload.inc.php';
    
    // instantiate and use the dompdf class
    $dompdf = new Dompdf();
    $dompdf->loadHtml('hello world');
    
    // (Optional) Setup the paper size and orientation
    $dompdf->setPaper('A4', 'landscape');
    
    // Render the HTML as PDF
    $dompdf->render();
    
    // Output the generated PDF to Browser
    $dompdf->stream();
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-22
      • 2023-03-26
      • 1970-01-01
      • 2017-03-16
      • 2018-12-10
      相关资源
      最近更新 更多