Drupal is a registered trademark of Dries Buytaert
cms 2.1.3 Update released for Drupal core (2.1.3)! drupal 10.5.11 Update released for Drupal core (10.5.11)! drupal 11.3.11 Update released for Drupal core (11.3.11)! drupal 11.2.13 Update released for Drupal core (11.2.13)! drupal 10.6.10 Update released for Drupal core (10.6.10)! cms 2.1.2 Update released for Drupal core (2.1.2)! drupal 11.1.10 Update released for Drupal core (11.1.10)! drupal 10.5.10 Update released for Drupal core (10.5.10)! drupal 10.4.10 Update released for Drupal core (10.4.10)! drupal 11.2.12 Update released for Drupal core (11.2.12)! drupal 11.3.10 Update released for Drupal core (11.3.10)! drupal 10.6.9 Update released for Drupal core (10.6.9)! drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)! drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)!

This module integrates Drupal with Go-WkhtmltoX.

Installation

Install as usual, see Installing Drupal 8 Modules or Installing modules' Composer dependencies for further information.

Configuration

Add your endpoint to your settings.php

$config['go_wkhtmltox.settings']['endpoint'] = 'http://wkhtmltox:8080';

PDF example

use Drupal\go_wkhtmltox\API\Converter\ToPdfConverter;
use Drupal\go_wkhtmltox\API\Fetcher\DataFetcher;

$pdf = [
 '#type' => 'inline_template',
 '#template' => '<h1>Hello world!</h1>',
];

$pdf_data = (string) \Drupal::service('renderer')->renderPlain($pdf);
$converter = new ToPdfConverter();
$converter->setOption('extend', [
  'dpi' => '300',
  'image-dpi' => '300',
  'image-quality' => '100',
  'page-width' => '210mm',
  'page-height' => '297mm',
]);
$fetcher = new DataFetcher();
$fetcher->setParam('data', $pdf_data);
$pdf_file = \Drupal::service('go_wkhtmltox.client')->convert($converter, $fetcher);

Image example

use Drupal\go_wkhtmltox\API\Converter\ToImageConverter;
use Drupal\go_wkhtmltox\API\Fetcher\DataFetcher;

$pdf = [
  '#type' => 'inline_template',
  '#template' => '<h1>Hello world!</h1>',
];

$pdf_data = (string) \Drupal::service('renderer')->renderPlain($pdf);
$converter = new ToImageConverter();
$converter->setOption('format', 'png');
// Sets the minimum value, it'll be auto-calculated.
$converter->setOption('width', 0);
$converter->setOption('extend', [
  'transparent' => '--transparent',
  // This option isn't added by itself.
  // @see https://github.com/gogap/go-wkhtmltox/issues/8
  'quality' => '0',
]);
$fetcher = new DataFetcher();
$fetcher->setParam('data', $pdf_data);
$pdf_file = \Drupal::service('go_wkhtmltox.client')->convert($converter, $fetcher);

Sponsors

- Fundación UNICEF Comité Español

Activity

Total releases
2
First release
Sep 2025
Latest release
1 month ago
Release cadence
214 days
Stability
0% stable

Releases

Version Type Release date
1.0.0-beta2 Pre-release Apr 28, 2026
1.0.0-beta1 Pre-release Sep 26, 2025