From 841e5a6b7b4d5c6a1443176232eb48722095f520 Mon Sep 17 00:00:00 2001 From: Stu Cork Date: Sat, 11 Sep 2021 09:56:13 +0800 Subject: [PATCH 1/3] fix margin-element node and make margin_top optional --- client_code/PageBreak/__init__.py | 2 +- client_code/PageBreak/form_template.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client_code/PageBreak/__init__.py b/client_code/PageBreak/__init__.py index ea4e6844..5cabf103 100644 --- a/client_code/PageBreak/__init__.py +++ b/client_code/PageBreak/__init__.py @@ -13,7 +13,7 @@ class PageBreak(PageBreakTemplate): - def __init__(self, margin_top, **properties): + def __init__(self, margin_top=0, **properties): self.margin_node = _S(anvil.js.get_dom_node(self)).find(".margin-element") self.margin_top = margin_top self.init_components(**properties) diff --git a/client_code/PageBreak/form_template.yaml b/client_code/PageBreak/form_template.yaml index 613517f5..d8ee1d29 100644 --- a/client_code/PageBreak/form_template.yaml +++ b/client_code/PageBreak/form_template.yaml @@ -3,7 +3,7 @@ container: properties: {tooltip: '', background: '', foreground: '', border: '', visible: true, role: null, html: "\n
\n
\n
\n
\n\n\ + page-break-after:always;\"/>\n
\n
\n\n\ "} components: [] From 57b3346e0dafecef404eabdcb594592693f39737 Mon Sep 17 00:00:00 2001 From: Stu Cork Date: Sat, 11 Sep 2021 09:57:46 +0800 Subject: [PATCH 2/3] update change log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 835f13f4..8d24d547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ https://github.com/anvilistas/anvil-extras/pull/121 * storage - update and clear were missing from the documented api https://github.com/anvilistas/anvil-extras/pull/125 +* PageBreak - fix margin_top property and make it optional + https://github.com/anvilistas/anvil-extras/pull/137 ## Updates * Slider Component - bump javascript dependency and refactor. No changes to the component's public API. From ffffd34c4c8ce848e8e9b8f22d80bcc01fac6e88 Mon Sep 17 00:00:00 2001 From: Stu Cork Date: Sat, 11 Sep 2021 10:18:51 +0800 Subject: [PATCH 3/3] document margin_top and add a property description --- client_code/PageBreak/form_template.yaml | 9 +++++---- docs/guides/components/page_break.rst | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client_code/PageBreak/form_template.yaml b/client_code/PageBreak/form_template.yaml index d8ee1d29..01ce44b8 100644 --- a/client_code/PageBreak/form_template.yaml +++ b/client_code/PageBreak/form_template.yaml @@ -3,11 +3,12 @@ container: properties: {tooltip: '', background: '', foreground: '', border: '', visible: true, role: null, html: "\n
\n
\n
\n
\n\n\ - "} + page-break-after:always;\"/>\n
\n
\n\n"} components: [] is_package: true custom_component: true properties: -- {name: margin_top, type: number, default_value: 0, default_binding_prop: true} +- {name: margin_top, type: number, default_value: 0, default_binding_prop: true, description: Use to adjust whitespace at the top of each page in the generated pdf. This is an optional property and defaults to 0. Can be positive or negative. Negative numbers will reduce whitespace in the generated pdf.} diff --git a/docs/guides/components/page_break.rst b/docs/guides/components/page_break.rst index 33aafdd8..7d28fa3e 100644 --- a/docs/guides/components/page_break.rst +++ b/docs/guides/components/page_break.rst @@ -1,3 +1,7 @@ PageBreak ========= For use in forms which are rendered to PDF to indicate that a page break is required. + +The ``margin_top`` property is optional. In the generated pdf you may want more or less white space at the top of the page. +You can set the ``margin_top`` property to a positive/negative number to adjust the whitespace. +Most of the time this is unnecessary. This won't have any effect on the designer only the generated pdf.