Hook actionGetPdfRenderer

Informations

Allows modules to provide a custom PDF renderer This hook allows modules to provide a custom PDF renderer (PDFGenerator) for generating PDF documents like invoices, delivery slips, and order returns.
Hook actionGetPdfRenderer
Locations
BO
Type action
Origin core
Aliases
Description This hook allows modules to provide a custom PDF renderer (PDFGenerator) for generating PDF documents like invoices, delivery slips, and order returns.

This hook has an $array_return parameter set to true (module output will be set by name in an array, see explaination here).

Located in

Origin File
core classes/pdf/PDF.php

Parameters

[
    'template' => $template,      // Template type string (e.g., 'Invoice', 'OrderReturn')
    'orientation' => $orientation, // Page orientation ('P' for portrait, 'L' for landscape)
]

Expected return value

Return a PDFGenerator instance to use a custom renderer, or null to use the default TCPDF-based renderer.

Call of the Hook in the origin file

$renderers = Hook::exec(
    'actionGetPdfRenderer',
    [
        'template' => $template,
        'orientation' => $orientation,
    ],
    null,
    true
);

Example usage

public function hookActionGetPdfRenderer($params)
{
    // Use a custom PDF library for all templates
    return new MyCustomPdfGenerator($params['orientation']);
}

Use cases

This hook is useful when you need to:

  • Use a different PDF library (e.g., Dompdf, mPDF) instead of the default TCPDF
  • Apply custom PDF settings globally (fonts, margins, headers)
  • Implement PDF/A compliance for archiving
  • Add watermarks or security features to all generated PDFs