dompdf page number

前端 未结 2 644
旧巷少年郎
旧巷少年郎 2020-12-17 01:44

Hi I am using DOMPDF to generate PDF file, I would like to know how to get page number.

I have try the following as mention in FAQ page of DOMPDF. and not successful

2条回答
  •  误落风尘
    2020-12-17 02:23

    Where you have '1/1' being used to get $x, this won't work when you have more than 10 pages.

    A possible solution does mean editing "cpdf_adapter.cls.php", so the _add_page_text() function used the following just after the str_replace()... about line 790:

    if ($x < 0) $x = (($this->_width + $x) - $this->get_text_width($text, $font, $size));
    if ($y < 0) $y = (($this->_height + $y) - $this->get_font_height($font, $size));
    

    The idea is that you can pass in negative x/y coords, and they will work from the right/bottom edges.

    Then in the HTML thats sent to DOMPDF, I used:

    
    

    Or if you want to specify the x/y in px:

    
    

提交回复
热议问题