0

I've installed Entity Print in order to create PDF files. I've read the documentation to enable a twig template to customize the pdf output, but I don't know how to do simple things, in the twig file, like add a page header and footer, add a front page, etc. Are there any docs about how to customize it?

1

It depends on which print engine you're using. I am using the following entity-print.html.twig with the dompdf engine.

<html>
<head>
    <meta charset="utf-8">
    <title>{{ title }}</title>
    {{ entity_print_css }}
</head>
<body>
{# The footer is repeated on all pages and must be printed first. #}
<footer>
    {{  footer  }}
</footer>
{%  if cover_page  %}
<div class="cover-page">
    {{ cover_page }}
</div>
{%  endif  %}
{# The header is repeated after the cover page for all pages. #}
<header>
    {{  header  }}
</header>
<div class="page">
    {{ content }}
</div>
</body>
</html>

The header and footer must be styled with position: fixed, after which they are displayed on every page.

I haven't found any great combined reference for the entity print module, but searching for what you want to accomplish along with your print engine's name should be helpful.

  • Thank you for your answer. I installed WkHtmlToPdf, but only because It was the first option in the documentation. After read your answer I have installed dompdf and I will use this engine. I don't care the engine if I can do what I need. Thanks. – briast Jun 15 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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