Here's instructions how to install dompdf manually, since the official instructions only support installation through Composer.
Components I used:
- Drupal 8.7.5 on Debian stretch 9.9 with apache 2.4.25
- PHP 7.2.18-1, MariaDB5.5.5-10.1.38
- EntityPrint module 8.x-2.1+3-dev
- dompdf 0.8.3
Target folder: the 'vendor' folder in the site root folder. This means the 'vendor' folder in the same directory as the 'core' and 'modules' folders.
- Download the latest dompdf zip from https://github.com/dompdf/dompdf/releases. Do not use the Source code downloads.
- Unpack the zip in the vendor folder, so that the files end up in <siteroot>/vendor/dompdf/dompdf/
- Double check: the following file should now exist in this location: <siteroot>/vendor/dompdf/dompdf/src/Dompdf.php
Then, add the following to <siteroot>/vendor/autoload.php
require_once __DIR__ . '/dompdf/dompdf/lib/html5lib/Parser.php';
require_once __DIR__ . '/dompdf/dompdf/lib/php-font-lib/src/FontLib/Autoloader.php';
require_once __DIR__ . '/dompdf/dompdf/lib/php-svg-lib/src/autoload.php';
require_once __DIR__ . '/dompdf/dompdf/src/Autoloader.php';
Dompdf\Autoloader::register();
Add this BEFORE the 'return' line (last line of the file). Save and exit.
Check ownership and permissions of the new files.
Clear cache.
Done.
Check under /admin/config/content/entityprint:
- the notice about dompdf missing should be gone
- dompdf should be selectable in the PDF dropdown
extra checks:
go to url <site address>/entityprint/pdf/node/<some node id>
This should get you a pdf of that node
go to url <site address>/entityprint/pdf/node/<some node id>/debug
This should give you a html page of that pdf.
Final tip:
In the source of the html page you can retrieve the html elements and css classes to style the pdf with css.
Add your custom css to <site root>/modules/entity_print/css/entity-print.css
GLHF
Mark.
Comments
Comment #2
cpdp CreditAttribution: cpdp as a volunteer commentedComment #3
april26 CreditAttribution: april26 commentedThank you so much - this is so clear!
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous as a volunteer commentedThank you - as my hoster does not allow command line access and therefore also no composer.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedOh my word. I struggled a lot until I realised that the code above to be pasted into autoload.php should go before the last line of code which is
"return ComposerAutoloaderInitce58b5d98b41b71861b22b5cdcf13ed1::getLoader();"
For some reason I thought you meant it should be pasted on the last line of the document. Now it works.
Thanks for the manual instructions!
Comment #6
hazit CreditAttribution: hazit as a volunteer commentedThank you thank you thank you!
This is the clearest instruction I have seen yet on installing libraries without composer. Thankyou! :-)
Comment #7
lhubbert CreditAttribution: lhubbert commentedSending a virtual box of cookies your way - thank you for the very clear directions!
Comment #8
ab2211 CreditAttribution: ab2211 commentedHm, I get an 500er error, after putting the code to autoload.php.No, my fault, it works perfectly!Comment #9
kirankumar.sana CreditAttribution: kirankumar.sana commentedAwesome, it is working perfectly in v8.6 using entity_print 8.x-2.1. Thank you very much
Comment #10
VortexCentrum CreditAttribution: VortexCentrum commentedKudos.
Installed latest dompdf (1-0-2) in D9-2.5.
Works immediately.
This is my autoload.php - I put the lines from this page before Composer's "Require Once" because it seemed logical not to split the two lines of its instructions.
-----------------------------------------------------
<?php
//autoload dompdf no composer
require_once __DIR__ . '/dompdf/dompdf/lib/html5lib/Parser.php';
require_once __DIR__ . '/dompdf/dompdf/lib/php-font-lib/src/FontLib/Autoloader.php';
require_once __DIR__ . '/dompdf/dompdf/lib/php-svg-lib/src/autoload.php';
require_once __DIR__ . '/dompdf/dompdf/src/Autoloader.php';
Dompdf\Autoloader::register();
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit4eedd22b05121b4ddc49b49c1fb16ba5::getLoader();
--------------------------------------
Brilliantly clear instructions. I wish the whole of D8/9 was written in such a step by step fashion.
Comment #11
larowlanThanks, as there's nothing to action here, other than leaving this as a point of reference for people searching with a search engine, marking as closed