Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I would love to see mPDF headers and footers get some love. I will gladly help test...
Comment | File | Size | Author |
---|---|---|---|
#15 | mpdf_footers_and_headers-1619766-15.patch | 1.15 KB | Ada Hernandez |
#14 | mpdf_footers_and_headers-1619766-14.patch | 1.27 KB | Ada Hernandez |
Comments
Comment #1
jcnventura CreditAttribution: jcnventura commentedI'll try to see if I can find some time for that. If you feel brave and write a patch, it would help a lot :)
Comment #2
Aleksey Zubko CreditAttribution: Aleksey Zubko commentedWe need some alter-implementation in function print_pdf_mpdf_print_pdf_generate . And we will can alter $mpdf before $mpdf->WriteHTML($html);
For example $mpdf->SetHTMLFooter('my footer');
Comment #3
ChristianAdamski CreditAttribution: ChristianAdamski commentedI would need that for a customer as well. Specifically
Header: 1 image + date and specific message
Footer: a bunch of icons + page number
So this would require a possibility to inject/modify header/footer on a per-document basis.
As this is probably not specific for mpdf, generic hooks to write header and footer would be required in the abstract print_pdf hooks already?
Libraries not allowing or implementing this could fall back to simply prepending/append this?
I would like to help & code, but I do not feel qualified to decide on the best approach on this.
If somebody advises me on the desired structure of interfaces, I could work out the actual insertion/printing.
Comment #4
ChristianAdamski CreditAttribution: ChristianAdamski commentedI just saw, this is currently done by a bunch of per-library functions?
Is this the way to go?
Comment #5
jcnventura CreditAttribution: jcnventura commentedYes. I think the problem started with the fact that the header/footers in TCPDF is so specific, that no generic function would apply there. And when the other PDF libraries came along, the possibility of having a generic header/footer never crossed my mind.. Feel free to suggest something different if you have the time.
Comment #6
zoraxHi,
the function to override is in print_pdf_mpdf.pages.inc called print_pdf_mpdf_print_pdf_generate.
Just need to put :
$mpdf = new mPDF('UTF-8', $format);
$mpdf->SetHTMLFooter('my footer');
Can you just tell me how I can override this function ?
Regards,
Comment #7
zealfire CreditAttribution: zealfire commentedThis patch inserts page number within the footer but needs testing.Hope it helps.
@zorax you are going right but for this to work you need to initialize a variable like margin_footer and then pass it within the function where you are creating an instance of class.
Comment #8
zealfire CreditAttribution: zealfire commentedAttaching a new patch as previous included wrong details.
Comment #9
dianaalbert CreditAttribution: dianaalbert commentedHi,
I need to add a header and footer on my project too, as well as change the default margins.
I've tried to add the:
$mpdf->SetHTMLFooter('my footer');
And modify the $format with the margins I need (on the new mPDF)
In print_pdf_mpdf.pages.inc
And also tried on the hook print_pdf_mpdf_alter on my template.php
But nothing seems to work.. The margins are still the default ones and no footer is appearing. Any ideas why?
Comment #10
zoraxHere is my code modified in the print_pdf_mpdf.page.inc file.
It adds a footer and header :
Comment #11
mandclu CreditAttribution: mandclu commentedRather than hardcoding in a value which will likely only meet the needs of a single user, could the code be written to look for a tpl file and use the contents of that, if found?
Comment #12
virtuid CreditAttribution: virtuid as a volunteer commentedYou can use varius method for defining header and footer (and much more) using special HTML tags in node.tpl.php just check http://mpdf1.com/manual/index.php?tid=253
Comment #13
bisonbleu CreditAttribution: bisonbleu commentedThe link in #12 no longer works. Try this instead: https://mpdf.github.io/
Comment #14
Ada Hernandez CreditAttribution: Ada Hernandez at MTech, LLC commentedHello everyone, I've needed a footer with its page number and I'm using mpdf library and print_pdf_mpdf so I needed to do some changes for give that. print module support a section for footer in admin/config/user-interface/print/common so if I checked User-specified and set
Page {PAGENO} of {nb}
, so footer was printed after of content not in footer page, so I've created a patch for modifying and fix this issue,Comment #15
Ada Hernandez CreditAttribution: Ada Hernandez at MTech, LLC commentedthis is not a different patch I just changed the path to print,
Comment #16
alex.87 CreditAttribution: alex.87 as a volunteer commentedYou can also add it in template directly:
Comment #17
shevgenyFooter #15 ok.
Header?
Comment #18
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedComment #20
jcnventura CreditAttribution: jcnventura at 1xINTERNET commented