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.