Skip to content

Commit

Permalink
Merge pull request #137 from anvilistas/page-break
Browse files Browse the repository at this point in the history
fix margin-element node and make margin_top optional
  • Loading branch information
meatballs authored Sep 13, 2021
2 parents 095389f + ffffd34 commit 166b100
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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.
Expand Down
2 changes: 1 addition & 1 deletion client_code/PageBreak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions client_code/PageBreak/form_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ container:
properties: {tooltip: '', background: '', foreground: '', border: '', visible: true,
role: null, html: "<!--\nBased on the snippet at https://anvil.works/forum/t/plots-in-pdf-being-divided-between-two-pages/7774/5\n\
-->\n<div class=\"break-container\" style=\"overflow: hidden;\">\n <div style=\"\
page-break-after:always;\"/>\n <div style=\"margin-top: 0px;\"/>\n</div>\n\n\
<style>\n .break-container {\n border: 1px solid grey;\n }\n @media print\
\ {\n .break-container {\n border: none;\n }\n }\n</style>"}
page-break-after:always;\"/>\n <div class=\"margin-element\" style=\"margin-top:\
\ 0px;\"/>\n</div>\n\n<style>\n .break-container {\n border: 1px solid grey;\n\
\ }\n @media print {\n .break-container {\n border: none;\n }\n\
\ }\n</style>"}
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.}
4 changes: 4 additions & 0 deletions docs/guides/components/page_break.rst
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 166b100

Please # to comment.