How to Use Entity Print in Drupal 8

Parent Feed: 
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.


About the author

Daniel is a web designer from UK, who's a friendly and helpful part of the support team here at OSTraining.

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web