Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a PDF from HTML
    text
    copied!<p>I'm trying to create a PDF document from a HTML document. I am using DOMPDF to do this as every other one I found was either too complicated or required me to install something to the web server itself. I just need a very simple HTML to PDF and force download script of some kind. This is my code so far.</p> <p>It is working almost completely. The ONLY thing that isn't working is the images... For some reason... And it works when I echo the $html variable and load it into a page on it's own.</p> <p><strong>PHP</strong></p> <pre><code>include('dompdf/dompdf_config.inc.php'); $html = $html_header . formatFormResultDownload($userid) . $html_footer; $dompdf = new DOMPDF(); $dompdf-&gt;set_paper("a4"); $dompdf-&gt;load_html($html); $dompdf-&gt;render(); $dompdf-&gt;stream('User Gallery (' . date('Y-m-d H:i:s') . ').pdf'); </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;****&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;table border="1" cellpadding="10" width="100%"&gt; &lt;tr&gt; &lt;td width="50%"&gt;&lt;img src= "http://****.net/client/****/images/logo-large.gif"&gt;&lt;/td&gt; &lt;td width="50%"&gt;&lt;span&gt;&lt;strong&gt;Email&lt;/strong&gt;: ****@****.net&lt;/span&gt;&lt;br&gt; &lt;span&gt;&lt;strong&gt;Company Name&lt;/strong&gt;:****&lt;/span&gt;&lt;br&gt; &lt;span&gt;&lt;strong&gt;Company Email&lt;/strong&gt;:****&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;table border="1" cellpadding="10" width="100%"&gt; &lt;tr&gt; &lt;td align="center" width="25%"&gt;&lt;span&gt;&lt;img src= "http://****.net/client/****/index.php?option=com_datsogallery&amp;amp;view=sbox&amp;amp;catid=7&amp;amp;id=70635" style="width:200px" width="100%"&gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span&gt;&lt;strong&gt;IS Reference&lt;/strong&gt;: 70635&lt;/span&gt;&lt;br&gt; &lt;span&gt;&lt;strong&gt;Author&lt;/strong&gt;: Rob Speakman&lt;/span&gt;&lt;br&gt;&lt;/td&gt; &lt;td align="center" width="25%"&gt;&lt;span&gt;&lt;img src= "http://****.net/client/****/index.php?option=com_datsogallery&amp;amp;view=sbox&amp;amp;catid=7&amp;amp;id=71173" style="width:200px" width="100%"&gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span&gt;&lt;strong&gt;IS Reference&lt;/strong&gt;: 71173&lt;/span&gt;&lt;br&gt; &lt;span&gt;&lt;strong&gt;Author&lt;/strong&gt;: James Hearne&lt;/span&gt;&lt;br&gt;&lt;/td&gt; &lt;td align="center" width="25%"&gt;&lt;span&gt;&lt;img src= "http://****.net/client/****/index.php?option=com_datsogallery&amp;amp;view=sbox&amp;amp;catid=7&amp;amp;id=71177" style="width:200px" width="100%"&gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span&gt;&lt;strong&gt;IS Reference&lt;/strong&gt;: 71177&lt;/span&gt;&lt;br&gt; &lt;span&gt;&lt;strong&gt;Author&lt;/strong&gt;: James Hearne&lt;/span&gt;&lt;br&gt;&lt;/td&gt; &lt;td align="center" width="25%"&gt;&lt;span&gt;&lt;img src= "http://****.net/client/****/index.php?option=com_datsogallery&amp;amp;view=sbox&amp;amp;catid=7&amp;amp;id=71171" style="width:200px" width="100%"&gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span&gt;&lt;strong&gt;IS Reference&lt;/strong&gt;: 71171&lt;/span&gt;&lt;br&gt; &lt;span&gt;&lt;strong&gt;Author&lt;/strong&gt;: Makiko&lt;/span&gt;&lt;br&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>The PDF</strong></p> <p><img src="https://i.stack.imgur.com/f1t9s.png" alt="enter image description here"></p> <p>Thank you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload