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 ;)

shane birley’s picture

Hey, @Vako:

The Drupal 8 port moved. Unsure why it is not mentioned here (or I missed it).

https://www.drupal.org/project/printable

vako’s picture

Thank you Shane, when I search for Print PDF I get the old link at https://www.drupal.org/project/print
But why do we have two different projects with the same name? can't we continue with the old release? Just wondering ;)

rooby’s picture

@jcnventura:
Could we get a message put on the print project page about the printable module and then close this?

manuel.adan’s picture

Another "forked" module with apparently no real reasons for it ;(

jcnventura’s picture

@manuel.adan, there is a very good reason for it. 'print' is a PHP-reserved keyword, and as such it is not possible to have a 'print' module anymore in Drupal 8, as Symfony doesn't allow that.

rooby’s picture

So what about #5?

Why is this issue still open if there isn't going to be a D8 version of this module?

manuel.adan’s picture

@jcnventura, that's good to know, thank's. Currently, the doc page about module naming does not mention such restriction:

There are some important rules to follow when selecting a machine name:

It must start with a letter.
It must contain only lower-case letters and underscores.
It must not contain any spaces.
It must be unique. Your module should not have the same short name as any other module, theme, or installation profile you will be using on the site.
It should not be any of the reserved terms : src, lib, vendor, assets, css, files, images, js, misc, templates, includes, fixtures, Drupal.

I'm wondering if such restriction is mentioned elsewhere in the documentation. Actually there are some modules with a machine name that matches a PHP reserved keyword, like the key module or the PHP module.

solideogloria’s picture

Why is this issue still open if there isn't going to be a D8 version of this module?

There is, it just has a different name: https://www.drupal.org/project/printable

jrockowitz’s picture

It is also worth noting that the Entity Print module provides similar functionality but takes a completely different approach.

Entity Print allows you to print any Drupal entity (Drupal 7 and 8) or View (Drupal 8 only) to PDF.

The module is lightweight compared to other modules like the Print module, has full test coverage and is ready to be used in production for both D7 and D8.

-- From: https://www.drupal.org/project/entity_print

rooby’s picture

Status: Active » Fixed

Closing because this is done.

The new home of this module in Drupal 8 is https://www.drupal.org/project/printable

Status: Fixed » Closed (fixed)

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