I have started porting the print module to Drupal 8. After spending some time thinking about the ideal architecture it came apparent that a total overhall was needed, rather than simply a port to allow for making full use of the new Plugin API in Drupal 8.

My proposed architecture mainly centered around making use of plugins, one for each format (e.g. print, PDF). Each of these format plugins provides a form and methods for building and returning the response in that format.

The port is currently a simple proof of concept and is not yet fully featured. Formats can currently only be used on renderable entities (a print view mode is provided). There is no user interface yet, other than forms for format configuration.

One significant change is that I have moved the PDF generation out into a separate PDF API module, as PDF generation is something than can be reused elsewhere. The PDF API again uses plugins, each plugin being an adaptor to a PDF generation library such as WKHTMLTOPDF. This allows the calling code to use a single interface to interact with any number of PDF generation libraries.

I have changed the module name to "hardcopy" simply because "print" is a reserved keyword in PHP and cannot be used in namespaces.

Here are the sandboxes:
https://drupal.org/sandbox/splatio/2110621
https://drupal.org/sandbox/splatio/2117169

Comments

jcnventura’s picture

Great! I'm porting adsense to D8 first, as that module is less tied to the Drupal API. My lesson from porting print to D7 is to only start the port when the first betas come out.. I think I ended up doing the D7 port about 2 or 3 times.

Vako’s picture

Any updates on this port? it's been 4 years and am surprised there's only one comment on this page encouraging you to continue this good work. I 2nd that ;)