how to add custom dynamic text footer in laravel 4.2 using dompdf

2.1k views Asked by At

i have followed this example laravel-4-create-pdf-use-dompdf:

how to add custom dynamic footer

 $dompdf = \App::make('dompdf');
 $dompdf->loadHTML('<h1>naeem World!!</h1>');

anyone do have idea? or please suggest,

i also have followed this solution DOMPDF add a header and footer but it doesn't work correctly.

Edited:

i want $db_data['footer_text'] to be footer text to all the pages dynamically, its coming form database.

1

There are 1 answers

2
BrianS On BEST ANSWER

The solution from the link you provided should be enough. You just need to craft a more complete HTML document.

$html = <<<EOT
  <html>
  <head>
    <style>
      @page { margin-bottom: 50px; }
      .footer { position: fixed; bottom: -50px; margin: 10px; }
    </style>
  </head>
  <body>
    <h1>naeem World!!</h1>
    <h2>section 1</h2>
    <div style="page-break-before: always;"></div>
    <div class="footer">{$db_data['footer_text']}</div>
    <h2>section 2</h2>
  </body>
  </html>
EOT;
$dompdf = \App::make('dompdf');
$dompdf->loadHTML($html);