From de78c92808e82a2bcd3b4b9d29c1bed0cdcfbe3a Mon Sep 17 00:00:00 2001 From: Eymen Elkum Date: Tue, 26 Feb 2019 21:46:27 +0300 Subject: [PATCH] pdf template custom page size. (#1258) --- .../Espo/Resources/i18n/en_US/Template.json | 5 +++++ .../Resources/layouts/Template/detail.json | 4 ++-- .../metadata/clientDefs/Template.json | 22 +++++++++++++++++++ .../metadata/entityDefs/Template.json | 10 ++++++++- application/Espo/Services/Pdf.php | 3 +++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/application/Espo/Resources/i18n/en_US/Template.json b/application/Espo/Resources/i18n/en_US/Template.json index c6814a2fdf..3a70b1468a 100644 --- a/application/Espo/Resources/i18n/en_US/Template.json +++ b/application/Espo/Resources/i18n/en_US/Template.json @@ -14,6 +14,8 @@ "variables": "Available Placeholders", "pageOrientation": "Page Orientation", "pageFormat": "Paper Format", + "pageWidth": "Page Width (cm)", + "pageHeight": "Page Height (cm)", "fontFace": "Font" }, "links": { @@ -26,6 +28,9 @@ "Portrait": "Portrait", "Landscape": "Landscape" }, + "pageFormat": { + "Custom": "Custom Page Size" + }, "placeholders": { "today": "Today (date)", "now": "Now (date-time)" diff --git a/application/Espo/Resources/layouts/Template/detail.json b/application/Espo/Resources/layouts/Template/detail.json index a938d919de..ad5ee06869 100644 --- a/application/Espo/Resources/layouts/Template/detail.json +++ b/application/Espo/Resources/layouts/Template/detail.json @@ -14,10 +14,10 @@ [{"name":"header","fullWidth":true}], [{"name":"body","fullWidth":true}], [{"name":"pageOrientation"}, {"name":"pageFormat"}], + [{"name":"pageWidth"}, {"name":"pageHeight"}], [{"name":"fontFace"}, false], - [{"name":"topMargin"}, false], + [{"name":"topMargin"}, {"name":"bottomMargin"}], [{"name":"leftMargin"}, {"name":"rightMargin"}], - [{"name":"bottomMargin"}, false], [{"name":"printFooter"}, false], [{"name":"footer","fullWidth":true}], [{"name":"footerPosition"}, false] diff --git a/application/Espo/Resources/metadata/clientDefs/Template.json b/application/Espo/Resources/metadata/clientDefs/Template.json index 4d2ffaddc8..ca57688c29 100644 --- a/application/Espo/Resources/metadata/clientDefs/Template.json +++ b/application/Espo/Resources/metadata/clientDefs/Template.json @@ -43,6 +43,28 @@ } ] } + }, + "pageWidth": { + "visible": { + "conditionGroup": [ + { + "type": "equals", + "attribute": "pageFormat", + "value": "Custom" + } + ] + } + }, + "pageHeight": { + "visible": { + "conditionGroup": [ + { + "type": "equals", + "attribute": "pageFormat", + "value": "Custom" + } + ] + } } } }, diff --git a/application/Espo/Resources/metadata/entityDefs/Template.json b/application/Espo/Resources/metadata/entityDefs/Template.json index 4e00d12d5d..d62fc2d09d 100644 --- a/application/Espo/Resources/metadata/entityDefs/Template.json +++ b/application/Espo/Resources/metadata/entityDefs/Template.json @@ -78,9 +78,17 @@ }, "pageFormat": { "type": "enum", - "options": ["A3", "A4", "A5", "A6", "A7"], + "options": ["A3", "A4", "A5", "A6", "A7", "Custom"], "default": "A4" }, + "pageWidth": { + "type": "int", + "min": 1 + }, + "pageHeight": { + "type": "int", + "min": 1 + }, "fontFace": { "type": "enum", "options": [ diff --git a/application/Espo/Services/Pdf.php b/application/Espo/Services/Pdf.php index d3cb9aa87d..733b8e1f34 100644 --- a/application/Espo/Services/Pdf.php +++ b/application/Espo/Services/Pdf.php @@ -109,6 +109,9 @@ class Pdf extends \Espo\Core\Services\Base if ($template->get('pageFormat')) { $pageFormat = $template->get('pageFormat'); } + if ($pageFormat === 'Custom') { + $pageFormat = [$template->get('pageWidth') * 10, $template->get('pageHeight') * 10]; + } $pageOrientationCode = 'P'; if ($pageOrientation === 'Landscape') { $pageOrientationCode = 'L';