Skip to content

Commit e5844dc

Browse files
committed
fix position of elements in PDF after page break
1 parent 47e237b commit e5844dc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

plugins/cell.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105

106106
jsPDFAPI.cell = function (x, y, w, h, txt, ln, align) {
107107
var curCell = getLastCellPosition();
108+
var pgAdded = false;
108109

109110
// If this is not the first cell, we must change its position
110111
if (curCell.ln !== undefined) {
@@ -117,13 +118,14 @@
117118
var margins = this.margins || NO_MARGINS;
118119
if ((curCell.y + curCell.h + h + margin) >= this.internal.pageSize.height - margins.bottom) {
119120
this.cellAddPage();
121+
pgAdded = true;
120122
if (this.printHeaders && this.tableHeaderRow) {
121123
this.printHeaderRow(ln, true);
122124
}
123125
}
124126
//We ignore the passed y: the lines may have diferent heights
125127
y = (getLastCellPosition().y + getLastCellPosition().h);
126-
128+
if (pgAdded) y = margin + 10;
127129
}
128130
}
129131

@@ -393,6 +395,7 @@
393395

394396
tableHeaderCell = this.tableHeaderRow[i];
395397
if (new_page) {
398+
this.margins.top = margin;
396399
tableHeaderCell[1] = this.margins && this.margins.top || 0;
397400
tempHeaderConf.push(tableHeaderCell);
398401
}

0 commit comments

Comments
 (0)