diff --git a/application/Espo/Resources/i18n/en_US/Template.json b/application/Espo/Resources/i18n/en_US/Template.json index 49bea18798..2dcdfa8ef8 100644 --- a/application/Espo/Resources/i18n/en_US/Template.json +++ b/application/Espo/Resources/i18n/en_US/Template.json @@ -11,13 +11,21 @@ "bottomMargin": "Bottom Margin", "printFooter": "Print Footer", "footerPosition": "Footer Position", - "variables": "Available Placeholders" + "variables": "Available Placeholders", + "pageOrientation": "Page Orientation", + "pageFormat": "Paper Format" }, "links": { }, "labels": { "Create Template": "Create Template" }, + "options": { + "pageOrientation": { + "Portrait": "Portrait", + "Landscape": "Landscape" + } + }, "tooltips": { "footer": "Use {pageNumber} to print page number.", "variables": "Copy-paste needed placeholder to Header, Body or Footer." diff --git a/application/Espo/Resources/layouts/Template/detail.json b/application/Espo/Resources/layouts/Template/detail.json index cb52f59c26..0d2a4be426 100644 --- a/application/Espo/Resources/layouts/Template/detail.json +++ b/application/Espo/Resources/layouts/Template/detail.json @@ -13,6 +13,7 @@ [{"name":"variables","fullWidth":true, "view": "Template.Fields.Variables"}], [{"name":"header","fullWidth":true}], [{"name":"body","fullWidth":true}], + [{"name":"pageOrientation"}, {"name":"pageFormat"}], [{"name":"topMargin"}, false], [{"name":"leftMargin"}, {"name":"rightMargin"}], [{"name":"bottomMargin"}, false], diff --git a/application/Espo/Resources/metadata/entityDefs/Template.json b/application/Espo/Resources/metadata/entityDefs/Template.json index 13f3b4cf37..20d55be5a8 100644 --- a/application/Espo/Resources/metadata/entityDefs/Template.json +++ b/application/Espo/Resources/metadata/entityDefs/Template.json @@ -70,6 +70,16 @@ "type": "base", "notStorable": true, "tooltip": true + }, + "pageOrientation": { + "type": "enum", + "options": ["Portrait", "Landscape"], + "default": "Portrait" + }, + "pageFormat": { + "type": "enum", + "options": ["A3", "A4", "A5", "A6", "A7"], + "default": "A4" } }, "links": { diff --git a/application/Espo/Services/Pdf.php b/application/Espo/Services/Pdf.php index 7aa64298b7..17a1d8d104 100644 --- a/application/Espo/Services/Pdf.php +++ b/application/Espo/Services/Pdf.php @@ -125,7 +125,20 @@ class Pdf extends \Espo\Core\Services\Base $pdf->setPrintFooter(false); } - $pdf->addPage(); + $pageOrientation = 'Portrait'; + if ($template->get('pageOrientation')) { + $pageOrientation = $template->get('pageOrientation'); + } + $pageFormat = 'A4'; + if ($template->get('pageFormat')) { + $pageFormat = $template->get('pageFormat'); + } + $pageOrientationCode = 'P'; + if ($pageOrientation === 'Landscape') { + $pageOrientationCode = 'L'; + } + + $pdf->addPage($pageOrientationCode, $pageFormat); $htmlHeader = $htmlizer->render($entity, $template->get('header')); $pdf->writeHTML($htmlHeader, true, false, true, false, '');