html2PDF在本地工作,但不会在服务器上创建pdf(空白页)

问题描述 投票:1回答:0

我从2年开始编程,从几周开始学习CakePHP,实际上我是在实习中尝试部署网站。

我在使用Html2PDF时遇到了麻烦,因为它在本地版本上效果很好,但是在服务器上却没有(打开一个新页面,使用正确的url,但是pdf为空白)。

新打开的空白页包含以下错误消息(显示在f12调试控制台上):

加载资源失败:服务器响应状态为500(内部服务器错误)

Html2PDF代码:

function exportFicheVie() {
    $Equipement = $this->Equipement->getEquipement($_GET['Id']);
    $PersonnesRessources = $this->Equipement->getPersonnesRessourcesOfEquipement($_GET['Id']);
    $Prestataire = $this->Equipement->getPrestataireOfEquipement($_GET['Id']);
    $Verifications = $this->Equipement->getVerif($_GET['Id']);
    $Contrat = $this->Equipement->getContrat($_GET['Id']);
    if (count($Contrat)==0)
        $Contrat[0] = "Non";

    $Vide = array(
        "Prenom"=>"",
        "Nom"=>"",
        "NumPoste"=>"",
        "Mail"=>"",
        "Adresse"=>"",
        "Fax"=>"",
        "Telephone"=>""
    );

    if (count($PersonnesRessources)==0)
        $PersonnesRessources = array($Vide, $Vide);
    elseif (count($PersonnesRessources)==1)
        $PersonnesRessources[] = $Vide;

    if (count($Prestataire)==0)
        $Prestataire = $Vide;

    // convert in PDF
    require_once(__DIR__.'/../webroot/theme/plugins/html2pdf/vendor/autoload.php');    
    try
    {
        $Html2pdf = new HTML2PDF('P', 'A4', 'fr');
        $NbPages = $Html2pdf->pdf->getAliasNbPages();
        $NumPage = $Html2pdf->pdf->getAliasNumPage();
        include($Html2pdf->getHtmlFromPage(__DIR__.'/../View/Equipements/export_fiche_vie.ctp', $Equipement, $PersonnesRessources, $Prestataire, $NbPages, $NumPage));

        $Content = ob_get_clean();
        //$Html2pdf->setModeDebug();
        $Html2pdf->addFont('Century Gothic', 'normal', __DIR__.'/../webroot/theme/plugins/html2pdf/vendor/tecnickcom/tcpdf/fonts/centurygothic.php');
        $Html2pdf->addFont('Century Gothic Bold', 'normal', __DIR__.'/../webroot/theme/plugins/html2pdf/vendor/tecnickcom/tcpdf/fonts/centurygothic.php');
        $Html2pdf->setDefaultFont('Century Gothic');
        $Html2pdf->writeHTML($Content, isset($_GET['vuehtml']));
        $Html2pdf->Output('\FS-'.$_GET['Id'].'.pdf');
    }
    catch(HTML2PDF_exception $e) 
    {
        echo $e;
        exit;
    }
}

我不希望有奇迹的答案,因为这个问题在没有任何明确解决方案的情况下会出现很多,但是任何提示,建议或假设都将受到欢迎。这是我第一次将网站放置在真实服务器上,它们可能是我想念的一些明显的东西。

pdf web-deployment html2pdf
© www.soinside.com 2019 - 2024. All rights reserved.