This project is not covered by Drupal’s security advisory policy.
PDF Tools is a drupal module to make it easier to manipulate PDF files. It provides service definitions and interfaces
for PDF generation, manipulation, analysis and conversion. The default implementations of these services use local
command-line tools, contrib modules provide alternative implementations.
Generation
The pdf_tools.generator service handles the generation of PDF's from html content. The default implementation requires wkhtmltopdf is installed on the local machine. The pdf_tools_docker module provides an alternative implementation utilising the wkhtmltopdf container available on the docker network.
Example
// Convert an entity to a PDF file.
$generator = \Drupal::service('pdf_tools.generator');
$pdf_uri = $generator->entityToPDF($entity_load, 'view_mode', $options);
Alternatively we can convert a URL to a pdf.
// Convert an entity to a PDF file.
$generator = \Drupal::service('pdf_tools.generator');
$uri = $generator->generateFromUrl(
Url::fromRoute(
'entity.node.canonical',
[
'node' => 1,
],
[
'absolute' => TRUE,
]
)->toString(),
$options
);
Analysis
The pdf_tools.analyser service provides methods that extract information from PDF files. The default implementation
uses pdftk in the local command line.
Example
// Get the number of pages in the pdf document.
$analyser = \Drupal::service('pdf_tools.analyser');
$num_pages = $analyser->countPages('private://path/my.pdf');
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.- Project categories: Developer tools
8 sites report using this module
- Created by rlmumford on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
Releases
Development version: 2.x-dev updated 21 Apr 2026 at 15:36 UTC
