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.
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.
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:
- 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:
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.
…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).”?
Hi Steve, You need to install mbstring on your server
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?
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.
Hi Sandeep, did you ever resolve this issue? I too am having this and desperately need to resolve it. Any comments very much appreciated.
Is there write up like this for Entity Print and D7?
showing special characters as “?????”. is there any solution for that..? Thanks
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?
Hi Daniel would you be able to provide an article on styling the output of entity print?
Hi Luke. We do write tutorials on request for OSTraining members.
I am running PHP 7.0 and can’t get it to work.
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).
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?
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. 🙁