template: page orientation and format

This commit is contained in:
yuri
2018-03-15 12:19:43 +02:00
parent 56472d6746
commit b954a81630
4 changed files with 34 additions and 2 deletions
@@ -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."
@@ -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],
@@ -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": {
+14 -1
View File
@@ -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, '');