diff --git a/src/elementWriter.js b/src/elementWriter.js index 9b176bcf1..a630a12e2 100644 --- a/src/elementWriter.js +++ b/src/elementWriter.js @@ -298,7 +298,7 @@ ElementWriter.prototype.addFragment = function (block, useBlockXOffset, useBlock */ ElementWriter.prototype.pushContext = function (contextOrWidth, height) { if (contextOrWidth === undefined) { - height = this.context.getCurrentPage().height - this.context.pageMargins.top - this.context.pageMargins.bottom; + height = (this.context.getCurrentPage().height || this.context.getCurrentPage().pageSize.height) - this.context.pageMargins.top - this.context.pageMargins.bottom; contextOrWidth = this.context.availableWidth; } diff --git a/src/pageElementWriter.js b/src/pageElementWriter.js index 41f974aa6..b5e5ce7bd 100644 --- a/src/pageElementWriter.js +++ b/src/pageElementWriter.js @@ -111,9 +111,8 @@ PageElementWriter.prototype.commitUnbreakableBlock = function (forcedX, forcedY) this.writer.popContext(); var nbPages = unbreakableContext.pages.length; - if (nbPages > 0) { - // no support for multi-page unbreakableBlocks - var fragment = unbreakableContext.pages[0]; + for (let currentPage = 0; currentPage < nbPages; currentPage++) { + var fragment = unbreakableContext.pages[currentPage]; fragment.xOffset = forcedX; fragment.yOffset = forcedY;