How to Use Entity Print in Drupal 8

How to Use Entity Print in Drupal 8

An OSTraining member asked us how to configure the Entity Print module with Drupal 8.

This module allows you to make a PDF version of your nodes

I would recommend that you install Entity Print using Drush, because you will need to install also need to install a composer package. This package contains the library to create PDFs.

Here are the Drush commands to use:

  • drush dl entity_print
  • drush en entity_print

This will install and enable the module for you. However, you will still need to install the Composer files.

You should note here that I already have Composer installed. You can check for Composer by using this command:

  • composer diagnose

This will tell you if you have Composer setup correctly and what steps to take if anything is out of place. For more help, check here.

Now that we have verified that Composer is set up correctly, we can proceed.

  • Go to Configuration > Entity Print.

entitycomposer

As you can see above, you 2 choices for which composer package to install. In this example, I’ll choose dompdf. imply copy the line to your command line and the files should install automatically.

  • Simply copy the Dompdf line to your command line and the files should install automatically.
  • Refresh the page and you see the warning Yellow text has disappeared. You can install both options or a single one.
  • Make sure the PDF Engine you installed is selected.
  • Save the configuration.

afterinstallation

Now let’s make the Print feature accessible via the site:

  • Go to Structure > Content type
  • Select your content type dropdown and load the “Manage display” tab.
  • You should now see the disabled Entity Print field, as in the image below:

managedisplay

  • Drag the Entity Print field to the desired location in the layout.
  • Save your changes.
  • View the page and you should see something like this:

final

Congratulations, you have now installed Entity Print. Clicking the link should automatically start a PDF download.

Note: at this point, I did encounter an error because I was using PHP7. Everything worked correctly on PHP5.

Author

0 0 votes
Article Rating
Subscribe
Notify of
15 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Steve Oliver
Steve Oliver
6 years ago

…and what was the error, “Exception: Not implemented, please install mbstring or iconv in HTML5_InputStream->__construct() (line 79 of (webroot)/vendor/dompdf/dompdf/lib/html5lib/InputStream.php).”?

danielpickering
6 years ago
Reply to  Steve Oliver

Hi Steve, You need to install mbstring on your server
Thanks

Daniel

Sandeep jain
Sandeep jain
6 years ago

This module works fine with my local machine but with UAT server it is showing error for images – “Error generating document: Failed to generate PDF: Image not readable or empty /sites/all/themes/custom/aab/images/icon-advantage.png”. Whereas this image is accessible directly from browser. Is there any permission needs to be change for images folder, it is already 777?

Please help.

danielpickering
6 years ago
Reply to  Sandeep jain

Hi Sandeep,
It sounds like your server isn’t correctly controlling your drupal installation.
You should look at the system modules available and use one to check your site is fully configured properly.
Thanks

Daniel

James West
James West
4 years ago
Reply to  Sandeep jain

Hi Sandeep, did you ever resolve this issue?  I too am having this and desperately need to resolve it.  Any comments very much appreciated. 

hollik
hollik
6 years ago

Is there write up like this for Entity Print and D7?

Indrajith_kb
Indrajith_kb
5 years ago

showing special characters as “?????”. is there any solution for that..? Thanks

Luke Nicholson
Luke Nicholson
4 years ago

Hi, I am printing a table which was created in a view. I have adjusted the CSS of the theme to make the table widths custom, but this isnt reflected in my PDF. I want the column widths to be fixed and not adjusted according to what is in the cell. Any suggestions?

Luke
Luke
4 years ago

Hi Daniel would you be able to provide an article on styling the output of entity print?

steve
4 years ago
Reply to  Luke

Hi Luke. We do write tutorials on request for OSTraining members.

Stugazc
4 years ago

I am running PHP 7.0 and can’t get it to work.

Stugazc
4 years ago

This what I get:

Error: Please configure a pdf print engine. in Drupal\entity_print\Plugin\EntityPrintPluginManager->createSelectedInstance() (line 102 of home/my_site/willdoit/public_html/wildwoodfarms.willdoit4u.us/site/modules/entity_print/src/Plugin/EntityPrintPluginManager.php).

Hiral Vyas
Hiral Vyas
2 years ago

Hello, Thank you for this.

I have used this in Drupal8 and my site is multilingual. I am using English and Japanese both. When I try to download in Japanese language, it shows ???? in place of Japanese lanagugae characters.

Can you please guide me for this?

Thank You

imrodmartin
2 years ago
Reply to  Hiral Vyas

Hi Hiral,

It appears this is a long-standing issue for the module (https://www.drupal.org/project/issues/entity_print?text=language&status=Open&priorities=All&categories=All&version=All&component=All)

It may not be “workable” at all at this time. 🙁

aljarboufatma
8 months ago

I have a question, I did use entity print with Dompdf but there is problem with Arabic Characters after print as pdf, there are any tips on how to solve it? thank you

15
0
Would love your thoughts, please comment.x
()
x