- 🇳🇱Netherlands sorson
I try to get a custom size paper working with Wkhtmltopdf. I created a new event Subscriber, but it doesn't work because --page-width and --page-height options are not supported, and only setting the paper size using the default_paper_size option is supported.
The subscriber works with:
$update_config = [ 'default_paper_size' => 'A4', ];
But not with:
$update_config = [ 'page_width' => '2.5in', 'page_height' => '3.5in', ];
Any direction how I can define a custom paper size with Wkhtmltopdf?
- 🇳🇱Netherlands sorson
I got a quick hard coded solution working.
In /modules/contrib/entity_print/src/Plugin/EntityPrint/PrintEngine/PhpWkhtmlToPdf.php:
$this->pdf = new Pdf([ 'binary' => $this->configuration['binary_location'], 'orientation' => $this->configuration['default_paper_orientation'], 'username' => $this->configuration['username'], 'password' => $this->configuration['password'], 'page-size' => $this->configuration['default_paper_size'], 'zoom' => $this->configuration['zoom'], 'viewport-size' => $this->configuration['viewport_size'], 'page-width' => '2in', 'page-height' => '2in', ]);
This could be implemented as a nice feature to the module. I will try to create a patch to propose to merge it, if I can find some time.