Part of the PDF ecosystem · 20 projects
PDF Tools is a Drupal module that simplifies PDF manipulation, offering services for generating, modifying, analyzing, and converting PDF files. It provides default implementations using local command-line tools and allows for alternative implementations through contributed modules, such as using Docker for PDF generation.
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');
Ask your assistant about PDF Tools
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.
More in the PDF ecosystem
Most installed first
Activity
Release Timeline
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 2.0.0-alpha3 | Pre-release | 10–11 | Nov 2, 2026 | ||
| 2.0.0-alpha2 | Pre-release | 9–10 | May 15, 2023 | ||
| 2.0.0-alpha1 | Pre-release | 9–10 | May 15, 2023 | ||
| 2.x-dev | Dev | 9–10 | May 15, 2023 |