簡體   English   中英

未捕獲的錯誤:Class“DOMImplementation”

[英]Uncaught Error: Class "DOMImplementation"

我有一個應用程序 php mvc 在帶有 apache2 的 xammp 中運行“OK”。但現在我需要移動到 debian 服務器 11,帶有 apache2、php 8.1。

使用在 pdf 中生成報告的頁面,我在 apache2 的日志中遇到了未捕獲的錯誤:Class“DOMImplementation”。我在谷歌上搜索了這個錯誤,但答案對我不起作用。

我的代碼生成了一個 html 頁面,我通過 echo 測試它並且沒問題,但沒有生成 pdf。

我調用 dompdf 的代碼是這樣的:

class xyz
{
use Exception;
use PDO;
use Dompdf\Dompdf;
use Dompdf\Options;

public function montaPDF($inform)
{
        $options = new Options();
        $options->isFontSubsettingEnabled(false);
        $options->isRemoteEnabled(true);
        $pdf = new Dompdf($options);
        $html = '<!DOCTYPE html>
                    <html lang="pt-br">
                    <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    </head><body>';         
        $html .= '</body></html>';                  
        $pdf->loadHtml($html); **//the error occur in this part**
        
                $pdf->render();
        $pdf->stream("dompdf_out.pdf", array("Attachment" => false));

}
}

提前感謝大家閱讀並嘗試提供幫助!

謝謝大家!特別是aynber! 解決了!

sudo apt-get install php8.1-xml:有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM