Help to use this module

Created on 8 June 2025, 4 months ago

After about a month of researching how to use the "Entity PDF" module, I've consolidated all my findings in one place to help anyone who needs this module as well.

This is my scenario. I need to create a PDF with a custom style for issuing training certificates in courses. This PDF will be printed and has a different style than the rest of my website's theme. I created a content-type "certificates".

After installing the module, create a new "view mode" called "PDF"
It is in the path "/admin/structure/display-modes/view"

Access the content-type that will need to generate the PDF.
In my case: /admin/structure/types/manage/certificates/display/pdf

Move the "View PDF" field from "disabled fields" to the list of visible fields.

Copy the file "entity-print.html.twig" from "modules\contrib\entity_print\templates"

Paste the file into your theme. In my case, it is in "themes\custom\subtheme_barrio\templates\content\entity-print.html.twig"

Create a new file "node--certificates--pdf.html.twig" in "themes\custom\subtheme_barrio\templates\content\node--certificates--pdf.html.twig
This is the file that should be customized according to your needs

If you need to use fields, you can use this format:

{{ content.field_user.0['#title'] }} - if it is a taxonomy
{{ content.field_trainning_date.0['#value']|date('d/m/Y') }} - if it is a smartdate field

In the file "themes\custom\subtheme_barrio\subtheme_barrio.info.yml", add this information:

entity_print:
node:
# Adds the all-nodes library to all node PDF’s.
all: 'subtheme_barrio/print-styling'

In the file "themes\custom\subtheme_barrio\subtheme_barrio.libraries.yml", add this information:
print-styling:
version: VERSION
css:
theme:
css/print-style.css: {}

Create a file "print-style.css" in this folder: "themes\custom\subtheme_barrio\css\print-style.css"
Style this file according to your needs

I hope it helps!

💬 Support request
Status

Active

Version

2.16

Component

Documentation

Created by

🇧🇷Brazil adao.boscolo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024