template: page orientation and format
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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, '');
|
||||
|
||||
Reference in New Issue
Block a user