Not counting cover page

65 views
Skip to first unread message

Tomas Rimkus

unread,
Apr 2, 2014, 4:14:27 AM4/2/14
to dom...@googlegroups.com
First of all I would like to thank developers for making the best html to pdf php library (I have tried html2pdf, tcpdf, wkhtmltopdf, princexml). It's easy to use and the resulting pdf looks exactly as html full of various CSS rules. I'd say the results are as good as you get with princexml which costs 495$ per single user. If I could make a small donation I would definitely do it :)

Anyway, here are few things I wanted to ask:
* I guess there is still no way to add total page count with simple CSS like you can do in princeXML (counter(pages))
* How do I skip cover page when using php script for inserting page numbers? I know I can insert page count with something like the following:
<script type='text/php'>
      if ( isset($pdf) ) {
        $font = Font_Metrics::get_font('helvetica', 'normal');
        $size = 9;
        $y = $pdf->get_height() - 24;
        $x = $pdf->get_width() - 15 - Font_Metrics::get_text_width('1/1', $font, $size);
        $pdf->page_text($x, $y, '{PAGE_NUM}/{PAGE_COUNT}', $font, $size);
      }
</script>
The problem is that it also counts cover page and shows the page number on the cover page which I don't want it to do.
* I don't want to have the script mentioned in the previous question inside of html file as it will be edited by some other people. How could I add it using php code?


PS: there are some undefined variables in cpdf_adapter.cls (lines 820-831) ($_t, $x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle, $code). Is this intentional?

BrianS

unread,
Apr 4, 2014, 6:12:34 PM4/4/14
to dom...@googlegroups.com
Thank you so much for the compliments! We do appreciate it. You are lucky to not have had to deal with one of the shortcomings, but we do think the library has advanced nicely over the years.

Regarding your questions:

1) not yet

2) If your cover page is a known entity then you can use an object to contain the header content and move your script to where page two starts. Something like the following would work (untested ... excuse any logic/syntax errors):

<html>
<body>
  <div id="cover-page-container" style="page-break-after: always;">
    <h1>My Cover Page</h1>
  </div>
  <script type='text/php'>
  if ( isset($pdf) ) {
    $font = Font_Metrics::get_font('helvetica', 'normal');
    $size = 9;
    $y = $pdf->get_height() - 24;
    $x = $pdf->get_width() - 15 - Font_Metrics::get_text_width('1/1', $font, $size);
    $pdf->page($x, $y, '{PAGE_NUM}/{PAGE_COUNT}', $font, $size);
  }
  </script>
  <p>All work and no play make dompdf something, something ...</p>
</body>
</html>


This works because of the way dompdf parses and renders elements.


As for the PS: Undefined as in causing PHP to throw a notice? Definitely not intentional. If you can post a bug report to remind us we'll look into it.
Reply all
Reply to author
Forward
0 new messages