Currently, the module doesn't provide any way of printing pdf for an entity revision. There is also no way of generating a pdf version of the latest revision page i.e /node/%nid/latest
Steps to follow:
1. Enable entity print module
2. Enable the content moderation module for workflows to have the latest revisions
3. Make necessary changes in the manage display as per the entity print module configuration
4. Create a node and published
5. Create multiple revisions with the latest revision (keep in draft)
6. Click on View pdf of the latest revision and check the changes if available
7. Now, apply the patch -> clear all cache
8. Go to that node's latest revision
9. Click on View pdf of the latest revision and check the changes if available
Comment | File | Size | Author |
---|---|---|---|
#21 | entity_print-revision_support-2979386-21.patch | 7.37 KB | DiDebru |
#20 | interdiff_14_20.txt | 2.42 KB | mkindred |
#20 | entity_print-revision_support-2979386-20.patch | 7.05 KB | mkindred |
#16 | After patch - pdf.png | 65.53 KB | DeepaliJ |
#16 | before patch - pdf.png | 75.13 KB | DeepaliJ |
Comments
Comment #2
ameymudras CreditAttribution: ameymudras as a volunteer commentedCreated a very basic patch that would provide revision support to the entity print module. With this patch, you can print node revisions as PDF's with URL such as print/pdf/node/%nid/%revision_id and also access the nodes latest revision using print/pdf/node/%nid/latest
Comment #3
benjy CreditAttribution: benjy at Unearthed commentedI don't think the renderer should have anything to do with the request, this seems like the wrong approach.
Can we hook in earlier, and pass the loaded revision entities to this method instead?
Comment #4
ameymudras CreditAttribution: ameymudras as a volunteer commentedThanks, benjy I have updated the patch by loading the entity in the controller itself.
Comment #5
benjy CreditAttribution: benjy at Unearthed commentedI don't like revision_id being latest, does this get the currently published revision or the forward most revision? I think i'd prefer for that to be a separate route.
I'm also wondering if the access control needs to handle revisions as well?
This shouldn't be hard-coded to node, it needs to work for all entity types. We probably need to check if the entity type supports revisions?
Comment #6
sushylAdding a patch to support revisions for entity_print debug.
@benjy,
@benjy, I have changed $revision_id to $revision, since we are reusing the same controller method, I thought it'd be simpler to keep them together. Please confirm if we still need to add new route for 'latest' revision.
Comment #8
sushyl$revision in the last patch did not work and throws missing mandatory argument error. Fixed and re-submitting patch.
Comment #9
benjy CreditAttribution: benjy at Unearthed commentedComment #11
Elin Yordanov CreditAttribution: Elin Yordanov commentedI've created a new patch. Please review.
Comment #12
KapilV CreditAttribution: KapilV as a volunteer and at Innoraft for Drupal Care, Drupal Association commentedComment #13
KapilV CreditAttribution: KapilV as a volunteer and at Innoraft for Drupal Care, Drupal Association commentedComment #14
Elin Yordanov CreditAttribution: Elin Yordanov commentedNew try
Comment #15
Elin Yordanov CreditAttribution: Elin Yordanov commentedComment #16
DeepaliJ CreditAttribution: DeepaliJ at Salsa Digital commentedVerified and applied patch #14 on Drupal 10.1.x-dev version with entity print v8.x-2.x-dev
The patch applied cleanly.
Steps:
1. Enable entity print module
2. Enable the content moderation module for workflows to have the latest revisions
3. Make necessary changes in the manage display as per the entity print module configuration
4. Create a node and published
5. Create multiple revisions with the latest revision (keep in draft)
6. Click on View pdf of the latest revision and check the changes if available
7. Now, apply the patch -> clear all cache
8. Go to that node's latest revision
9. Click on View pdf of the latest revision and check the changes if available
Result:
After applying the patch, able to print entity revisions as well.
Refer to the attached screenshots
Revision
Before patch pdf:
After patch pdf:
RTBC +1
Comment #17
DeepaliJ CreditAttribution: DeepaliJ at Salsa Digital commentedComment #18
Shubham Rathore CreditAttribution: Shubham Rathore at Dotsquares Ltd. commentedComment #19
Shubham Rathore CreditAttribution: Shubham Rathore at Dotsquares Ltd. commentedHi verified and applied patch #14 on Drupal 10.1.x-dev version setup. The patch applied successfully and cleanly.
Thanks.
Comment #20
mkindred CreditAttribution: mkindred commentedI need to create PDFs of revisions, so I tried #14, but it didn't work for me. Although it alters the controller to accomodate printing revisions from PDFs, it seems to be lacking the {revision_id} path parameter for the entity_print.revision.view and entity_print.revision.view.debug routes.
Also, I couldn't apply the patch via git apply due to a case mismatch in EntityPrintController.php:
@TODO
should be@todo
in the patch. This case change was made back in #3104331.I made the following changes to #14 and got it working for my purposes:
{revision_id}
path parameter to the entity_print.revision.view and entity_print.revision.view.debug routesI'm sure that my revision to entity_print_entity_view_alter() (to alter the View PDF link) is the wrong way to go about this, so consider this patch to be in-progress. It assumes that there's always a revision id, and it works for my specific use case so far. But I'm sure this needs to be improved.
@benjy can I get some feedback on the overall direction of the patch?
Comment #21
DiDebruFix fatal error:
Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "revision_id" for route "entity_print.revision.view" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 206 of core/lib/Drupal/Core/Routing/UrlGenerator.php).