I am using Commerce Invoice and Entity Print to generate .pdf-files of invoices. In Entity Print settings, I set the paper size to A4 and selected TCPDF as printing engine.

Then, I customized commerce-invoice.html.twig to my needs, which works fine.

But I cannot get rid of the two black borders that seperate the document header and footer I think.

enter image description here

Would be nice if anyone could give me a hint where these come from. I alread also tried to override entity-print.html.twig and remove the styles from there. Also I unchecked the checkbox in the entity-print settings. enter image description here

But these borders still appear on every .pdf-generation.

Thank you very much in advance!

  • 2
    Inspect them with browser developer tools. I'm thinking they might be horizontal line elements (<hr>) and not borders. They are probably separating printing header and footer, where you might add printing info (page numbers, date of printing, etc).
    – prkos
    Commented May 14, 2021 at 21:56
  • @prkos Thanks for the answer! I thought of that myself already. But I completely stripped down the commerce-invoice.html.twig (which contains all the HTML and TWIG of the actual print document), as well as the entity-print.html.twig, which is practically the "parent" wrapping commerce-invoice.html.twig. And in both there's no <hr> as well as no css. But yes, it's possible these are <hr>s, but I cannot figure out where they come from. I assume they appear when the document is actually printed as .pdf and are "injected" in this process somewhere... Commented May 14, 2021 at 22:07
  • 1
    It can't be investigated remotely, you have to debug, test, and poke around to find out where it's coming from. Turn on the print stylesheets in your browser dev tools and inspect. Also turn twig debug on to get template suggestions, this will help in investigating which template might hold the hr elements, if that's what they are.
    – prkos
    Commented May 14, 2021 at 22:26
  • @prkos Yes, I know. I just thought someone might have wanted to remove them already. In the meanwhile, I switched to DOMpdf as printing-engine, and the "borders" are gone. So it has to be somewhere inside TCPDF rendering/converting. I'll have to dig deeper and more. But thanks man! Commented May 14, 2021 at 22:29
  • 2
    @BerryDingle When you have the time, pease summarize your findings as an answer to your own question, to help others in the future. 😊 Commented May 15, 2021 at 11:33

1 Answer 1


What I found out is:

Every available printing engine has it's own requirements for the HTML-structure of the generatred invoice.

TCPDF needs a header and footer-tag inside the document. If you dont provide this elements, TCPDF will render them empty, but will in fact attach an hr-tag after the empty header and before the empty footer.

I switched to DOMpdf as printing engine, which also offers the possibility to define a page header and footer, but ignores them when empty and doesn't render any additional HTLM by default.

pro: DOMpdf supports more CSS rules and makes it easier to style the invoice with CSS

con: DOMpdf takes some seconds to render/print the document from the HTML, while TCPDF is very fast.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.