Answers.Body: <p>I've not yet tested specifically with Printmaker (only Laravel + Dompdf), but you should be able to add page numbers by using a special <code>&lt;script&gt;</code> block in the template you use for PDF rendering. This block's PHP instructions will be interpreted by Dompdf as it renders your document, so you can position additional elements like page numbers, headers/footers, etc.</p>
  
  <p>Example of what you'd include <em>in your Twig template</em>:</p>
  
  <pre><code>&lt;script type='text/php'&gt;
  if ( isset($pdf) ) {
      $font = $fontMetrics-&gt;get_font('Proxima Nova', 'normal');
      $size = 9;
      $y = $pdf-&gt;get_height() - 32;
      $x = ($pdf-&gt;get_width() / 2) - ($fontMetrics-&gt;get_text_width('1 of 1', $font, $size) / 2);
      $pdf-&gt;page_text($x, $y, '{PAGE_NUM} of {PAGE_COUNT}', $font, $size);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>More on the subject where I first learned about it: <a href="https://stackoverflow.com/a/13184208/897279">https://stackoverflow.com/a/13184208/897279</a></p>
  
  <hr>
  
  <p><strong>CRITICAL POINT:</strong></p>
  
  <p>Ensure PHP is enabled in <code>config/printmaker.php</code>...</p>
  
  <pre><code>'isPhpEnabled' =&gt; true,
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-03-21T22:06:59.810Z
Answers.LastActivityDate: 2019-11-05T21:55:56.820Z
Answers.LastEditDate: 2019-11-05T21:55:56.820Z
Answers.UserDisplayName: Matt Stein
Body: <p>Does somebody know if it's possible with <a href="https://printmaker.docs.topshelfcraft.com/" rel="nofollow noreferrer">Printmaker</a> to provide each page, of the PDF you generate, with a static footer and/or header?</p>
  
  <p>Printmaker makes use of the dompdf library. In the documentation of this library I found that <a href="https://dompdf.net/examples.php#print_header_footer.html,pdf" rel="nofollow noreferrer">this</a> is supported by the library.</p>
  
  <p>But I cannot find in the Printmaker documentation that you can also use this option with the plugin.</p>
  
  <p>I hope somebody can answer this question.</p>
  
  <p>Or does somebody know a plugin that I can use as an alternative, that does support this?</p>
  
Tags: <pdf><plugin-printmaker><dompdf>
Title: Generate PDF's (Printmaker plugin) with a static header and footer
ThreadText: # Generate PDF's (Printmaker plugin) with a static header and footer
  
  (Asked by: username_0 on 2017-03-20)
  
  Does somebody know if it's possible with [Printmaker](https://printmaker.docs.topshelfcraft.com/) to provide each page, of the PDF you generate, with a static footer and/or header?
  
  Printmaker makes use of the dompdf library. In the documentation of this library I found that [this](https://dompdf.net/examples.php#print_header_footer.html,pdf) is supported by the library.
  
  But I cannot find in the Printmaker documentation that you can also use this option with the plugin.
  
  I hope somebody can answer this question.
  
  Or does somebody know a plugin that I can use as an alternative, that does support this?
  
  **Tags:** pdf, plugin-printmaker, dompdf
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-21. Score: 2
  
  I've not yet tested specifically with Printmaker (only Laravel + Dompdf), but you should be able to add page numbers by using a special `<script>` block in the template you use for PDF rendering. This block's PHP instructions will be interpreted by Dompdf as it renders your document, so you can position additional elements like page numbers, headers/footers, etc.
  
  Example of what you'd include *in your Twig template*:
  
  ```
  <script type='text/php'>
  if ( isset($pdf) ) {
      $font = $fontMetrics->get_font('Proxima Nova', 'normal');
      $size = 9;
      $y = $pdf->get_height() - 32;
      $x = ($pdf->get_width() / 2) - ($fontMetrics->get_text_width('1 of 1', $font, $size) / 2);
      $pdf->page_text($x, $y, '{PAGE_NUM} of {PAGE_COUNT}', $font, $size);
  }
  </script>
  
  ```
  
  More on the subject where I first learned about it: <https://stackoverflow.com/a/13184208/897279>
  
  ---
  
  **CRITICAL POINT:**
  
  Ensure PHP is enabled in `config/printmaker.php`...
  
  ```
  'isPhpEnabled' => true,
  
  ```
  
  
  ---
  
  