DOMPDF generating blank pdf

I am using DOMPDF library 0.6.0 beta 3 to generate pdf files using PHP. Some of my html can be processed to PDF correctly and some not. Below is an example of one which can not. I have validated my html via w3c html validator. What can I do to resolve this issue?

<?php
  require_once("dompdf/dompdf_config.inc.php");
    $html = "<!DOCTYPE html>
            <html>
              <head>
              <title></title>
                      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
              </head>
             <body>
                 <p>Algarve Bird Watching Festival About to Begin</p>
                 <p><span style='font-family:calibri;font-size:11pt'>&nbsp;</span></p>
                 <p>Test Title</p>
                 <p>Lorem ipsum sit dolor amet<sup>th</sup> Lorem ipsum sit dolor amet </p>
                 <p>Lorem ipsum sit dolor amet</p>
                 <p>Lorem ipsum sit dolor amet </p>
                 <p>Lorem ipsum sit dolor amet <a href='http://www.test.com'>test</a>
                  Lorem ipsum sit dolor amet &nbsp; 
                  </p>
    <p><span style='font-family:calibri;font-size:11pt'>&nbsp;</span></p>
             </body>
             </html>";

    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper("a4", "portrait");
    $dompdf->render();
    $dompdf->stream();
?>

Answer

Check your double quotes:

$html = '<!DOCTYPE html>
        <html>
          <head>
          <title></title>
                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          </head>
         <body>
             <p>Algarve Bird Watching Festival About to Begin</p>
             <p><span style="font-family:calibri;font-size:11pt">&nbsp;</span></p>
             <p>Test Title</p>
             <p>Lorem ipsum sit dolor amet<sup>th</sup> Lorem ipsum sit dolor amet </p>
             <p>Lorem ipsum sit dolor amet</p>
             <p>Lorem ipsum sit dolor amet </p>
             <p>Lorem ipsum sit dolor amet <a href="http://www.test.com">test</a>
              Lorem ipsum sit dolor amet &nbsp; 
              </p>
<p><span style="font-family:calibri;font-size:11pt">&nbsp;</span></p>
         </body>
         </html>';

edit

furthermore, DOMPDF may not know the font calibri.


edit

You don’t have a <title> tag content. Could that be the cause?

Leave a Reply

Your email address will not be published. Required fields are marked *