Allow new rendering engines

Created on 20 September 2023, over 1 year ago
Updated 25 April 2024, 12 months ago

Problem/Motivation

I suggest to allow other pdf rendering engines (like puppeteer, which handles better modern css).

Aiming that, I propose to introduce a new service, a plugin collection, and a better cache handling.

API changes

As is, the module has no BC (route has exactly the same behavior).

The new service will also allow to render pdf in various custom use cases (in custom webform handler, in specific custom route, etc.), with a separate method generatePdf.

The new plugin system is introduced, as simple as bundled plugin Drupal\entity_pdf\Plugin\EntityPdfRenderingEngine\RenderingEngineMpdf.

These changes allows to bundle sub-modules with other generators, and also allows community or custom modules to emerge.

Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇫🇷France nicodh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nicodh
  • 🇫🇷France nicodh

    Sorry I forgot a bunch of code, new patch attached

  • Status changed to Needs work over 1 year ago
  • 🇧🇪Belgium weseze

    Great idea.
    I will have to make some time to test this.
    The patch does not apply cleanly anymore against latest version. Is it possible to update?

    But looking over the code I already have some feedback.

    1/

    function entity_pdf_update_8004() {
      \Drupal::service('kernel')->rebuildContainer();
    }
    

    We should not do that. When adding (or changing) services, we should provide a post_update hook (empty one is OK if I remember correctly) to force Drupal into clearing cache on updates and deployments.

    2/
    Found a "dump($form);": Probably not needed? Or it needs some documentation?

    3/
    We are introducing new settings, they should be defined in the config/schema/entity_pdf.schema.yml and defaults provided in the config/install/entity_pdf.settings.yml

  • 🇫🇷France nicodh

    Here is the patch with requested fixes.
    Made on 2.0.4 only

  • 🇫🇷France nicodh

    Rerolled with 2.0.5

    • weseze committed 2328ddcd on 2.x
      Issue #3388581 by rkcreation, weseze: Allow new rendering engines
      
  • 🇧🇪Belgium weseze

    The patch is working fine for me so I comitted it.

    Do you have actual implementations for other engine that we could include?

    Can you provide some documentation (for the readme and the project page) on how to create a new engine in a custom module?
    If we have that I would feel comfortable making a new release.

    Or I could add you as co-maintainer to work on that?

  • Status changed to Fixed about 1 year ago
  • 🇫🇷France nicodh

    Hi

    I've used a puppeteer rendering engine, with spatie/browsershot bridge. It works fine, but needs some host setup (to have nodejs available). But the render, with all CSS3 features, files links... it's amazing and easy to write compared to mpdf !
    I could write documentation about that, I just need some time to clean code :-)

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024