Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Go-WkhtmltoX

Security covered Under active development 2 sites

This module integrates Drupal with Go-WkhtmltoX, enabling the conversion of content to PDF or image formats.

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

Ask your assistant about Go-WkhtmltoX

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Sep 2025
Latest release
5 months ago
Releases (12 mo)
1
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.0-beta2 Pre-release 10–11 Apr 28, 2026
1.0.0-beta1 Pre-release 8–10 Sep 26, 2025