From b5b7f2b333dcdf2848224f69e0466de39dc6b546 Mon Sep 17 00:00:00 2001 From: Michael Finson <32094844+chaim0m@users.noreply.github.com> Date: Thu, 17 Oct 2019 11:42:00 +0300 Subject: [PATCH] Update pagebreaks.js Allow for creation of any type of HTML element to fill space between pages. Allow for styling of this element, this is especially important where for example one would like to remove borders on the added area (since its in a table/tr) but cannot do that with a div. All this can be accomplished by adding in the pagebreaks option for "elementType" and "className". --- src/plugin/pagebreaks.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugin/pagebreaks.js b/src/plugin/pagebreaks.js index 5a4dc2b..176ccf6 100644 --- a/src/plugin/pagebreaks.js +++ b/src/plugin/pagebreaks.js @@ -33,7 +33,9 @@ Worker.template.opt.pagebreak = { mode: ['css', 'legacy'], before: [], after: [], - avoid: [] + avoid: [], + elementType: 'div', //default element to create + className: '' //by default no class }; Worker.prototype.toContainer = function toContainer() { @@ -114,10 +116,10 @@ Worker.prototype.toContainer = function toContainer() { // Before: Create a padding div to push the element to the next page. if (rules.before) { - var pad = createElement('div', {style: { + var pad = createElement(self.opt.pagebreak.elementType, {style: { //allow for creating any type of element e.g. 'tr' (this is useful for tables and other cases where a 'div' will ruin the styling and cannot be handled by simply using the div selector as thats too broad. display: 'block', height: pxPageHeight - (clientRect.top % pxPageHeight) + 'px' - }}); + }, className: self.opt.pagebreak.className}); //allow control of styling of added sections el.parentNode.insertBefore(pad, el); }