1

I'm coding since 2 year and learning cakePHP since a few weeks , and i'm actually in internship trying to deploy a website.

I have trouble with Html2PDF , as it work well on the local version, but not on the server (a new page is opened , with the right url , but the pdf is blank).

the newly opened blank page contain this error message (displayed on the f12 debug console) :

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

the Html2PDF code :

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;
    }
}

I don't expect an miracle answer , because this question appear a lot without any clear solution , but any hint, advice or supposition would be welcome .it's my first time putting a website on a real server they might be some obvious things I miss.

alfo
  • 21
  • 1
  • 3
  • look at the error-log file. – Syan Souza Mar 15 '19 at 17:42
  • @Syan Souza I didnt know this thing existed, I was able to solve a few issue thanks to that, it appear that cake php need the writting right because it generate view, and the php admin on the server was on a different configuration (the local didnt have trouble with upper-case and one of the sql query i didnt write had a table name with an upper case). – alfo Mar 18 '19 at 11:48

0 Answers0