【问题标题】:Why am I getting an error when running my php code using dompdf?为什么在使用 dompdf 运行我的 php 代码时出现错误?
【发布时间】:2022-11-15 17:16:15
【问题描述】:

我正在尝试使用 dompdf 将我的 html 文档转换为 pdf。但是,我收到以下错误代码: 解析错误:语法错误,第 6 行 C:\xampp\htdocs\dompdf\pdf.php 中的意外“使用”(T_USE)

我的代码如下:

<?php

require_once '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();

?>

我使用以下文档来帮助开发上述代码: https://github.com/dompdf/dompdf

【问题讨论】:

    标签: php html dompdf pdf-conversion


    【解决方案1】:

    只需在require_once 'dompdf/autoload.inc.php' 之后添加;

    【讨论】:

      猜你喜欢
      • 2020-11-11
      • 1970-01-01
      • 1970-01-01
      • 2021-06-25
      • 1970-01-01
      • 2020-12-15
      • 2023-01-05
      • 2023-02-08
      • 1970-01-01
      相关资源
      最近更新 更多