Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dompdf ignores width attribute

Tags:

php

dompdf

I am trying to create a PDF that has three black boxes across the page. I have coded up the following..

  <?php
  require_once("dompdf_config.inc.php");

  $html =
    '
  <!DOCTYPE html>
  <html>
  <head>
  <meta charset="utf-8" />
  <title></title>
  <style type="text/css">

  .main
  {
  border: 0pt solid black;
  }
  .gutter
  {
  width: 100px;
  border: 1px solid black;
  }
  .card
  {
  width:50px;
  height:50px;
  border: 0px solid black;
  }
  </style>
  </head>
  <body>
  <table class="main" >
    <tbody>
      <tr>
        <td class="gutter"> </td>
        <td class="card"> </td>
        <td class="gutter"> </td>
        <td class="card"> </td>
        <td class="gutter"> </td>
      </tr>
    </tbody>
  </table>
  </body>
  </html>';

  $dompdf = new DOMPDF();
  $dompdf->load_html($html);
  $dompdf->render();
  $dompdf->stream("sample.pdf");
  ?>

The width attribute is completely ignored. I have 3 very narrow boxes in the top of the sheet.

like image 215
maxum Avatar asked Oct 18 '12 08:10

maxum


2 Answers

Try to write style width = 100% for table.

like image 88
Andrei Pasat Avatar answered Sep 21 '22 05:09

Andrei Pasat


Update the last vertion, it should to work,
dompdf_0-6-0_beta3
download https://code.google.com/p/dompdf/downloads/list

like image 23
Kakitori Avatar answered Sep 20 '22 05:09

Kakitori