Files
api/services/nginx/app/modules/html2pdf/html2pdf_templates.php
T
Jepp9350 45328a6b72 Add PDF generation module with HTML2PDF integration.
This commit introduces a new PDF generation module leveraging the HTML2PDF library. The module generates PDFs from HTML templates, supports customization through styles and templates, and integrates with Minio for storage and retrieval. A test route is added for generating and serving PDFs dynamically.
2025-03-14 14:56:55 +01:00

41 lines
1.3 KiB
PHP

<?php
namespace html2pdf;
require_once WD . '/modules/html2pdf/html2pdf_templates_i.php';
require_once WD . '/modules/html2pdf/helpers/html2pdf_template.php';
/** Template classes */
require_once WD . '/modules/html2pdf/templates/wash_certificate.php';
use Exception;
use html2pdf\helpers\html2pdf_template;
class html2pdf_templates implements html2pdf_templates_i
{
/**
* Get the template with the given name, and optionally pass data to it
* @param string $templateName Template name
* @param array|null $data Data to pass to the template
* @return html2pdf_template Template object
* @throws Exception If the template class does not exist
*/
public static function getTemplate(string $templateName, array $data = null): html2pdf_template
{
$className = self::getTemplateClass($templateName);
if (!class_exists($className)) {
throw new Exception('Template class does not exist: ' . $className);
}
return new $className($data);
}
/**
* Get the template class name based on the template name
* @param string $templateName Template name
* @return string Class name of the template
*/
public static function getTemplateClass(string $templateName): string
{
return 'html2pdf\\templates\\' . $templateName;
}
}