Using Stylesheets

Using stylesheets for your PDF documents is as simple as adding a CSS or even LESS file with the same name as the loaded document:

/** @var RockPdf $pdf */
$pdf = $modules->get('RockPdf');
$pdf
  ->load("/site/test.php")
  ->save(preview: true);

Then just add /site/test.css:

h1 {
  color: red;
}
RockPdf - Using Stylesheets

LESS

RockPdf supports LESS parsing out of the box - just create /site/test.less:

.second {
  td {
    border: 1pt solid red;
    padding: 2mm;
    text-align: center;
  }
}
<h1>Hello World</h1>

<table class="w-full mt5">
  <tr>
    <td>foo</td>
    <td>bar</td>
    <td>baz</td>
  </tr>
</table>

<table class="w-full mt5 second">
  <tr>
    <td>foo</td>
    <td>bar</td>
    <td>baz</td>
  </tr>
</table>
RockPdf - Using Stylesheets

On this page