The screenshot below shows my Entity Print configurations for created styled PDFs from node content. enter image description here

As shown in the screenshot I am using the phpwkhtmltopdf engine and the mikehaertl/phpwkhtmltopdf package is installed via composer.

However, when I try generating the target PDF, the following errors results:

Error generating document: Failed to generate PDF: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 1: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: cannot open ?php: No such file /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 2: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: namespace: not found /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 4: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: use: not found /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 6: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: /bin: Permission denied /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 7: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: INSTALL.txt: not found /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 8: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: INSTALL.txt: not found /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 9: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: INSTALL.txt: not found /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 10: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: INSTALL.txt: not found /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: 12: /opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: Syntax error: newline unexpected

I gave Pdf.php 777 permissions too.

Can anyone help, please?

2 Answers 2


/opt/drupal/vendor/mikehaertl/phpwkhtmltopdf/src/Pdf.php: cannot open ?php: No such file

You need to install the missing library using composer

composer require mikehaertl/phpwkhtmltopdf

In addition, you might also need h4cc/wkhtmltopdf, see Entity Print documentation

  • mikehaertl/phpwkhtmltopdf was already installed at the time of my post. That's how I was able to trace the path to the Pdf.php script. What I'm concerned about is if the path I configured correct. I also installed the h4cc/wkhtmltopdf package as you suggested and using the same settings as before, the error continued to be an issue.
    – sisko
    Nov 14, 2020 at 2:51
  • 1
    I was wrong about h4cc/wkhtmltopdf installing. I later notice it failed to install because there was no installation candidate. I had to use apt-get install wkhtmltopdf. Also, the PDF engine path in the screenshot is incorrect. It sould be point to the path wkhtmltopdf
    – sisko
    Nov 14, 2020 at 6:27

here The location has to be configured as per this picture

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.