diff --git a/application/Espo/Resources/i18n/en_US/Template.json b/application/Espo/Resources/i18n/en_US/Template.json index 3ad6005d9a..a4d008d156 100644 --- a/application/Espo/Resources/i18n/en_US/Template.json +++ b/application/Espo/Resources/i18n/en_US/Template.json @@ -18,7 +18,8 @@ "pageFormat": "Paper Format", "pageWidth": "Page Width (mm)", "pageHeight": "Page Height (mm)", - "fontFace": "Font" + "fontFace": "Font", + "title": "Title" }, "links": { }, diff --git a/application/Espo/Resources/layouts/Template/detail.json b/application/Espo/Resources/layouts/Template/detail.json index a13ae46743..3b53cf8342 100644 --- a/application/Espo/Resources/layouts/Template/detail.json +++ b/application/Espo/Resources/layouts/Template/detail.json @@ -33,6 +33,7 @@ { "label": "", "rows": [ + [{"name": "title"}, false], [{"name":"printHeader"}, {"name":"headerPosition"}], [{"name":"header","fullWidth":true}], [{"name":"printFooter"}, {"name":"footerPosition"}], diff --git a/application/Espo/Resources/metadata/entityDefs/Template.json b/application/Espo/Resources/metadata/entityDefs/Template.json index 7fae2f38fe..4f4e6685d0 100644 --- a/application/Espo/Resources/metadata/entityDefs/Template.json +++ b/application/Espo/Resources/metadata/entityDefs/Template.json @@ -100,6 +100,9 @@ "type": "enum", "view": "views/template/fields/font-face", "default": "" + }, + "title": { + "type": "varchar" } }, "links": { diff --git a/application/Espo/Tools/Pdf/Tcpdf/EntityProcessor.php b/application/Espo/Tools/Pdf/Tcpdf/EntityProcessor.php index 07f4f5dd90..1393272cc5 100644 --- a/application/Espo/Tools/Pdf/Tcpdf/EntityProcessor.php +++ b/application/Espo/Tools/Pdf/Tcpdf/EntityProcessor.php @@ -72,6 +72,11 @@ class EntityProcessor $fontFace = $template->getFontFace(); } + if ($template->hasTitle()) { + // @todo Support placeholders. + $pdf->SetTitle($template->getTitle()); + } + $pdf->setFont($fontFace, '', $this->fontSize, '', true); $pdf->setAutoPageBreak(true, $template->getBottomMargin()); diff --git a/application/Espo/Tools/Pdf/Template.php b/application/Espo/Tools/Pdf/Template.php index fcc5ed6684..2e25895be7 100644 --- a/application/Espo/Tools/Pdf/Template.php +++ b/application/Espo/Tools/Pdf/Template.php @@ -62,4 +62,8 @@ interface Template public function getPageWidth(): float; public function getPageHeight(): float; + + public function hasTitle(): bool; + + public function getTitle(): string; } diff --git a/application/Espo/Tools/Pdf/TemplateWrapper.php b/application/Espo/Tools/Pdf/TemplateWrapper.php index 4d03cbbbe2..754f90946b 100644 --- a/application/Espo/Tools/Pdf/TemplateWrapper.php +++ b/application/Espo/Tools/Pdf/TemplateWrapper.php @@ -119,4 +119,14 @@ class TemplateWrapper implements Template { return $this->template->get('pageHeight') ?? 0.0; } + + public function hasTitle(): bool + { + return $this->template->get('title') !== null; + } + + public function getTitle(): string + { + return $this->template->get('title') ?? ''; + } }