Reviewed & tested by the community
Project:
Entity Print
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 Mar 2019 at 22:26 UTC
Updated:
14 Jul 2024 at 15:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mindaugasd commentedUpdated patch, download url was wrong previously.
Comment #3
mindaugasd commentedComment #4
mindaugasd commentedFound the problem, Ludwig does not support this loading type.
Just wrote about it in Ludwig issues here https://www.drupal.org/project/ludwig/issues/2914840#comment-13025150
As a temporary solution attached a patch - it works!
Comment #5
mecurran commented@mindaugasd do you have the autoload.inc.php file in the lib/dompdf-dompdf/v0.8.3/ directory?
I am asking because when I add require_once('lib/dompdf-dompdf/v0.8.3/autoload.inc.php'); to my entity.module I get this error:
Fatal error: require_once(): Failed opening required 'lib/dompdf-dompdf/v0.8.3/autoload.inc.php' (include_path='/srv/bindings/ee6d52a3ec7948d99223654c03fba695/code/vendor/pear/archive_tar:/srv/bindings/ee6d52a3ec7948d99223654c03fba695/code/vendor/pear/console_getopt:/srv/bindings/ee6d52a3ec7948d99223654c03fba695/code/vendor/pear/pear-core-minimal/src:/srv/bindings/ee6d52a3ec7948d99223654c03fba695/code/vendor/pear/pear_exception:.:/usr/share/pear:/usr/share/php') in /srv/bindings/ee6d52a3ec7948d99223654c03fba695/code/modules/contrib/entity_print/entity_print.module on line 8
Comment #6
mindaugasd commentedYes, I have this file
/public_html/modules/entity_print/lib/dompdf-dompdf/v0.8.3/autoload.inc.phpMaybe you get this error because you don't have this file placed there?
Comment #7
mecurran commentedI had downloaded the library from https://github.com/dompdf/dompdf/archive/v0.8.3.zip. Which actually is NOT dompdf-0.8-3 (it is dompdf-0.8-2.3), and which doesn't have the autoload.inc.php file. Downloading the library from https://github.com/dompdf/dompdf/releases/download/v0.8.3/dompdf_0-8-3.zip, resolves that issue as it includes the autoload.inc.php file as well as a few others. Thank you for the require_once solution - works like a charm :)
Comment #8
mindaugasd commentedWelcome. Correct URL is listed in the patch itself https://www.drupal.org/files/issues/2019-03-16/ludwig-3040695-4.patch
Comment #9
mandus.cz commentedIt works! Thanks.
Please add to the new release.
Comment #10
devad commentedThnx @mindaugasd
I suppose it would be good to
require_once()php file conditionally - if Ludwig module exists only. To avoid "File not found" errors for composer users.New patch attached.
Comment #11
devad commentedAfter digging a bit deeper into Entity Print module composer installation it came to the surface that dompdf/dompdf library is not the only one which has to be included into ludwig.json file.
Three other libraries are required by dompdf/dompdf library either directly or indirectly (by it's child libraries).
Here is the full list of (currently) required libraries from composer report:
So, all these libraries should be added to
ludwig.jsonfile in order for Entity Print module to work nicely in full capacity.In other words, this means that Entity Print module is on the edge of being convenient to be managed by Ludwig. Proper Ludwig support would require some manual work from Entity Print module maintainers when new release is published, plus some manual work from site managers when module update time comes.
Comment #12
devad commentedComment #13
devad commentedComment #14
mmjvb commentedSounds like the three libraries mentioned in #11 are needed as well.
Obviously, the dependency management is for the users, not the maintainers of this module. Would consider it their decision to support this or not.
Comment #15
devad commented@mmjvb
Dependency management with Ludwig is simple if you have 1 or 2 PSR dependencies.
Here is a kind of mess which can arise if you have more libraries to manage by Ludwig. Example is from Search Api Solr project which abandoned Ludwig integration because it's issue queue had been flooded with ludwig issues:
#3082306: Fatal Error with Symfony Event Dispatcher when installing via ludwig instead of composer
#3082582: Search API Solr - Dropped Ludwig support
No one can handle such a mess. Except Composer of course. :)
Entity Print module do not have a lot of library dependencies (4), so it is up to mainteners to decide to add official Ludwig support or not.
Comment #16
devad commentedComment #17
devad commentedComment #18
devad commentedUndo. :)
Comment #19
devad commentedComment #20
devad commentedThe
dompdf/dompdflibrary has "classmap" autoload part which is not supported by Ludwig yet.New Ludwig 8.x-1.1 will display a warning about the 'classmap' autoload type for
dompdf/dompdflibrary.Read more at comment #15 here: #2914840-15: Add support for 'classmap' and 'files' autoload types
Manual integration with Ludwig is possible still, with one-line addition to
entity_print.modulefile described in comment #9 in the same issue.The all-in-one patch is attached.
The new Ludwig 8.x-1.1 will display a warning about the 'classmap' autoload type for
dompdf/dompdflibrary still, but withrequire_once('lib/dompdf-dompdf/v0.8.6/autoload.inc.php');added toentity_print.modulefile you can safely ignore the warning.Comment #21
devad commentedHere is the extended
ludwig.jsonfile for those who would like to use an optionalmikehaertl-phpwkhtmltopdflibrary for printing.I have tested. The
mikehaertl-phpwkhtmltopdflibrary and all of its dependencies are standard PSR-4 libraries and they work nicely with Ludwig.Please, note also that an another optional
tecnickcom/tcpdfprinting library is the 'classmap' autoload type and its integration with current Ludwig 8.x-1.1 is not supported.Comment #22
devad commentedComment #23
devad commentedLudwig 8.x-1.2 released few days ago has added a new ludwig.json option:
"disable_warnings": "TRUE"This option can be used nicely by Entity Print module to suppress a "Classmap autoload type is not supported" warning for dompdf/dompdf library which is implemented manually inside .module file.
This is just an UX improvement. New patch attached.
Interdiff is just:
Comment #24
devad commentedHi
This is the improved patch which adds integration in
entity_print.modulefile independent of future library version changes.Comment #25
devad commentedMoving "if Ludwig module exists" part of code to the Helper function for simplicity reasons.
Comment #26
devad commentedMoving the Ludwig Helper function 'ludwig_require_once' to new ludwig.inc file so that any script (.module, .install, ...) can require it in the future if needed.
A note for Entity Print module maintainers
Please, note that with patch #26 in place, if the new version of
dompdf/dompdflibrary will be required by some future Entity Print module release, onlyludwig.jsonfile will need to be updated accordingly to mirror the newcomposer.jsonfile.So, maintaining of Ludwig integration will take just a few minutes for maintainers once in a few months... or years... depending on how often the
dompdf/dompdflibrary versions change.If you would like to make happy all the Drupal 8/9 users not familiar with Composer yet - you can add the official Ludwig integration to Entity Print module (by committing patch #26).
Ludwig module has nice and very detailed documentation added to Drupal.org recently.
Ludwig is improved a lot in last 2 months, including stabile D9 release.
It has 6700+ users currently and very steady Weekly usage increase despite opinions that "Everybody is using Composer nowadays". :)
Comment #27
devad commentedIgnore this patch.
Comment #28
devad commentedIn Ludwig ver. 8.x-1.5 a new Ludwig service is added which can be used instead of ludwig.inc file here.
The 'files' and 'classmap' libraries integration with Ludwig are more simple now.
New patch attached.
Comment #29
devad commentedPatch 28 is a different approach using new
ludwig.require_onceservice. So, no need for interdiff.Comment #30
devad commentedPatch reroll for new Ludwig 8.x-1.6 (due to slight service API change).
#2914840-20: Add support for 'classmap' and 'files' autoload types
One line interdiff:
Comment #31
Duvan.Slabbert commentedRan into some errors with Drupal 9.2.3 and PHP 8. I used some of patch 30 code to resolve issues and came up with this.
Comment #32
devad commentedRe: #31
Your PHP8 issue is not directly connected with Ludwig. It is a general issue with older versions of dompdf/dompdf library reported here:
#3227149: [PHP8] Update the recommended dompdf from 0.8.0 to 1.0.2
Thanks for reporting. New Ludwig patch very similar to your post #31 is here. Please try it and report back if it works for you.
Note: PHP8 tests fail is related to: #3227262: [PHP8] Tests fail
Comment #33
vortexcentrum commentedHi
I know I'm being thick but I claim a steep learning curve after years of working in D5/6/7 and hating D8 so much I had a dalliance (divorce in progress) with WordPress.
D9 is, I'm learning, getting back to the idea that Drupal's success lay with the fact that it could be used by content creators without significant input from techies.
Ludwig is a major part of that puzzle. Thanks to everyone working on its integration. I really don't like using the command line on the server and, in any case, for some reason SSH doesn't like connecting from my location.
In relation to Entity Print (here's the really thick bit) of all the patches that have been posted here, is there one that resolves all the dependencies at once and, if so, which is it?
I'm on PHP7.4 or 7.3 depending on which site I'm working on.
Thanks.
Comment #34
devad commentedRe: #33
Patch #32 should be just fine. You can try it and report back if it works for you.
Comment #35
devad commentedComment #36
vortexcentrum commented@Devad
Thanks for the very prompt reply. I realise that I'm in a discussion with people who know what they are talking about and I'm struggling to keep up.
So I spent a long time this morning trying to identify what I'm doing wrong and how to solve it.
I also realise that it's far more likely that my problem is not specific or limited to this module but rather a my current lack of familiarity with all things D9.
So I'm sorry if I'm being a nuisance.
This is what I've done:
I first tried inserting the patch into entity_print_module here:
*****************
<?php
/**
* @file
* Print any entity.
*/
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\entity_print\Renderer\ContentEntityRenderer;
diff --git a/entity_print.module b/entity_print.module
index 0c372a4..967a590 100644
--- a/entity_print.module
+++ b/entity_print.module
@@ -12,6 +12,12 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\entity_print\Renderer\ContentEntityRenderer;
+// Ludwig module integration.
******* et seq ****************
I cleared the cache, ran "Report > Packages" but there was no mention of entity print.
Next
I restored the original file entity_print_module.
Next I created ludwig.json on the desktop using a text editor to insert the full content of the patch and uploaded it by FTP to [site]/modules.entity_print.
Again, cleared the cache, ran the report and there was no mention of entity print.
I'm at a loss as to where I should put the patch.
I found https://www.drupal.org/docs/contributed-modules/ludwig/ludwig-integratio... by The Commerce Guys but Reports shows "Download and unpack missing packages (0)" and does not mention Entity Print. The page refers to a ""Download all missing libraries" button but I don't have that. I should say that it's working fine for Commerce and Stripe integration.
Can anyone set out an idiot's guide (for, not by, idiots) as to exactly what goes where and that assumes zero knowledge and will help many like me who are very happy to see Ludwig.
Thanks.
Comment #37
devad commentedThanks @VortexCentrum. I have fixed the button name inconsistency inside Ludwig module documentation. Your reply was helpful.
Regarding your need for help with applying patches with Git... your question is not directly connected with this issue here. I will try to help you here with a few words and links... but if you will need more help I suggest that you post your questions at some Drupal or Git help forum... so that we do not continue to post here a bunch of off-topic questions.
----------
Here is a help link on how to apply a patch to Entity Print module:
https://www.drupal.org/node/2412091/git-instructions/8.x-2.x/nonmaintainer
If you have a zero knowledge about command line tools like Git I recommend that you learn it from scratch.
https://www.drupal.org/docs/develop/git/setting-up-git-for-drupal
https://www.drupal.org/docs/develop/git/introduction-to-drupal-git
It is a whole big new area to learn but once you learn it - it will make your developer life easier and you will be more ready to learn other useful command line tools like Composer and Drush.
If you are not ready to go to the learning way... this article can help you to properly understand all parts of the diff files and may help you to learn how to copy/paste needed line changes manually. If .diff file (.patch file) has just a few lines like in our case it might be a quick solution for you. There is also a helpful Wikipedia example here: https://en.wikipedia.org/wiki/Diff
------------
After you apply patch #32 properly to your files your entity_print.module file should have 5 new lines of code added between the previously existed lines.
And your newly created ludwig.json file should have this content:
Comment #38
Duvan.Slabbert commentedUpdated patch for 8.x-2.6
Enviroment:
Drupal: 9.4.5
php: 8
Entity Print: 8.x-2.6
entity_print.module
ludwig.json
Comment #39
devad commentedHere is a new patch with all library versions updated. Please review.
Comment #40
devad commentedComment #41
dd 85 commentedPatch #39 works great!
I strongly recommend that the maintainers add it to the next release of the module.
@devad thanks a lot!