1

I am using DOMPDF to make an invoice. I need to have a few div's side by side. The float element is not working. I am trying to get Column 2 beside Column 1

<?php
require_once "dompdf/dompdf_config.inc.php";

$dompdf = new DOMPDF();

$html ='
<html>
<link type="text/css" href="pdf.css" rel="stylesheet"/>
 <body>

<div class="columns">
    <div class="red" >Column 1</div>
    <div class="grey">Column 2</div>
    <div class="red" >Column 3</div>
</div>
<div class="clear"></div>

 </body>
</html>
';

$dompdf->load_html($html);
$dompdf->render();

//$dompdf->stream("hello.pdf");

$dompdf->stream('my.pdf',array('Attachment'=>0));

?>

Below is the CSS

div.columns       { width: 50%; }
div.columns div   { width: 50%; height: 100px; float: left; }
div.grey          { background-color: #cccccc; }
div.red           { background-color: #e14e32; }
div.clear         { clear: both; }
ToyotaMR2
  • 141
  • 2
  • 10

1 Answers1

0

Add External Style Sheet Path:

$dompdf->set_base_path('(FilePath)/pdf.css');

After:$dompdf->render();

Note that the CSS selectors are case sensitive in dompdf.

Read http://code.google.com/p/dompdf/wiki/CSSCompatibility or Git https://github.com/dompdf/dompdf/wiki/CSSCompatibility

Refer DOMPDF doesn't work with external css file

CSS not working with DOMPDF

Community
  • 1
  • 1