Reputation: 79
I have to produce a document in this situation:
page 1 <- in the footer: "page 1 of 3"
page 2 <- in the footer: "page 2 of 3"
page 3 <- in the footer: "page 3 of 3"
page 5 <- no page number
page 6 <- no page number
This is an example, the total pages number can vary and also the first part of numbered pages. I have tried the inline php code of dompdf FAQ link
I failed to do it. And I want avoid the inline php code for security reasons. How can solve this issue?
Thanks
Upvotes: 1
Views: 637
Reputation: 13914
You could do this using the page_script()
method which is a method of running a script per-page after the document has fully rendered. It gives you access to all the variables you need to generate the desired output.
You would, of course, have to write some logic to determine how many pages get the footer. If you don't know how many pages need the footer in advance you could use a global variable to store a value indicating on what page to stop.
Probably the difficult aspect of this is writing code that writes code. I've mocked up a sample that I think captures what you want. You can find it here: http://eclecticgeek.com/dompdf/debug.php?identifier=ed03c2020546641d3e830a7c0115c8ae
Unfortunately it's not possible to generate what you want without scripting right now. You could add the script via the $dompdf object rather than as inline script ($dompdf->get_canvas()->page_script()
). Then you could filter out any inline script/PHP from the user document.
(Also answered on the support group: https://groups.google.com/d/topic/dompdf/3x_8YHctCp0/discussion)
Upvotes: 1