MPDF No Output (Blank Page)

user975343 picture user975343 · Oct 12, 2011 · Viewed 16.1k times · Source

I'd installed the MPDF utility in order to convert HTML&CSS to PDF reports. So far things have been working just fine, until I've tried converting certain page to PDF ,and there's no output.

I have to mention that i'm able to display the page regularly through browser - the problem only comes up when i'm trying to convert it to PDF - then I receive blank page. Moreover, there are no encoding problems (part of the output is written in Hebrew, but I've already overcame this obstacle)

Here's part of the code :

if($customer!=$tempCustomer)
{


    if($tempCustomer!="")
    {
    $html.=("</table>");
    $html.=("</BR>סהכ".$sumTotal."</BR>");
    $html.=("</BR>משטחים".$sumPallets."</BR>");
    }
    $sumTotal=0; //RESET SUM OF EACH CUSTOMER
    $sumPallets=0; //RESET PALLETS COUNT
    $html.=("</div>");
    $html.=("<div class='subTable'>");
//  $html.=("לקוח: ".$customerName."</br>");
    $sumTotal=0;
    $sumPallets=0;
    $tempCustomer=$customer;
        $html.=("<table border='3' 

<tr><td>מגדל</td><td>תאריך</td><td>תעודה</td><td>פריט</td><td>סוג</td><td>גודל</td><td>כמות</td><td>משקל</td><td>מחיר  

מכירה</td><td>סכום</td><td>משטחים</td></tr>");
    $html.=("<tr>");
    $html.=("<td>".$grower."</td>");
    $html.=("<td>".$date."</td>");
    $html.=("<td>".$form."</td>");
    $html.=("<td>".$item."</td>");
    $html.=("<td>".$type."</td>");
    $html.=("<td>".$size."</td>");
    $html.=("<td>".$quantity."</td>");
    $html.=("<td>".$weight."</td>");
    $html.=("<td>".$price."</td>");
    $html.=("<td>".$total."</td>");
    $html.=("<td>".$pallet."</td>");
    $html.=("</tr>");
    $sumTotal+=$total;
    $sumPallets+=$pallet;

}
else
{
    $html.=("<tr>");
    $html.=("<td>".$grower."</td>");
    $html.=("<td>".$date."</td>");
    $html.=("<td>".$form."</td>");
    $html.=("<td>".$item."</td>");
    $html.=("<td>".$type."</td>");
    $html.=("<td>".$size."</td>");
    $html.=("<td>".$quantity."</td>");
    $html.=("<td>".$weight."</td>");
    $html.=("<td>".$price."</td>");
    $html.=("<td>".$total."</td>");
    $html.=("<td>".$pallet."</td>");
    $html.=("</tr>");
    $sumTotal+=$total;
    $sumPallets+=$pallet;

}

/*
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");

$html.=("</tr>");
*/
}

$html2='אבדרכדכגכגכגכג';

$html3='אבדרכדכגכגכגכג';

//==============================================================
//MPDF SETTINGS  - CONTINUE
$mpdf->SetAutoFont();

$mpdf->autoFontGroupSize = 1;


$mpdf->SetDirectionality('rtl');

$mpdf->useLang = true;

$mpdf->WriteHTML($html);

$mpdf->Output();
exit;

Any suggestions?

Thanks in advance

Answer

Alexey Gerasimov picture Alexey Gerasimov · Nov 14, 2011

Have you tried debugging it? Per mpdf's site: If you get nothing but a blank screen on your browser, it may be because there is a script error. Turn on debugging at the start of your script.

<?php
include("../mpdf.php");
$mpdf=new mPDF();

$mpdf->debug = true;

$mpdf->WriteHTML("Hallo World");
$mpdf->Output();
?>

If the above works, then it's something with your code. Sometime, even a single space before any html output can throw off MPDF