Skip to content

Commit

Permalink
Fixes issues 928 2121 2720 921\n\nFixes issue 2799\n\nFixes PR 2778 (#…
Browse files Browse the repository at this point in the history
…2801)

Co-authored-by: fe-cj <[email protected]>
  • Loading branch information
fe-cj and fe-cj authored Oct 30, 2024
1 parent a801fda commit 48ce2ab
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 83 deletions.
14 changes: 13 additions & 1 deletion src/DocumentContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ class DocumentContext extends EventEmitter {
this.addPage(pageSize);
}

beginColumnGroup(marginXTopParent) {
beginColumnGroup(marginXTopParent, bottomByPage = {}) {
this.snapshots.push({
x: this.x,
y: this.y,
availableHeight: this.availableHeight,
availableWidth: this.availableWidth,
page: this.page,
bottomByPage: bottomByPage ? bottomByPage : {},
bottomMost: {
x: this.x,
y: this.y,
Expand All @@ -46,6 +47,16 @@ class DocumentContext extends EventEmitter {
}
}

updateBottomByPage () {
const lastSnapshot = this.snapshots[this.snapshots.length - 1];
const lastPage = this.page;
let previousBottom = -Number.MIN_VALUE;
if (lastSnapshot.bottomByPage[lastPage]) {
previousBottom = lastSnapshot.bottomByPage[lastPage];
}
lastSnapshot.bottomByPage[lastPage] = Math.max(previousBottom, this.y);
}

resetMarginXTopParent() {
this.marginXTopParent = null;
}
Expand Down Expand Up @@ -118,6 +129,7 @@ class DocumentContext extends EventEmitter {
this.availableHeight -= (y - saved.bottomMost.y);
}
this.lastColumnWidth = saved.lastColumnWidth;
return saved.bottomByPage;
}

addMargin(left, right) {
Expand Down
Loading

0 comments on commit 48ce2ab

Please sign in to comment.