Skip to content

Commit d2a0c03

Browse files
committed
Merge pull request #454 from zky829/zky829-fix-right-align
Fix right alignment in table cells
2 parents 381e14e + a8a24f0 commit d2a0c03

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

jspdf.plugin.cell.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@
124124
this.rect(x, y, w, h);
125125
}
126126
if (align === 'right') {
127-
if (txt instanceof Array) {
128-
for(var i = 0; i<txt.length; i++) {
129-
var currentLine = txt[i];
130-
var textSize = this.getStringUnitWidth(currentLine) * this.internal.getFontSize();
131-
this.text(currentLine, x + w - textSize - padding, y + this.internal.getLineHeight()*(i+1));
132-
}
127+
if (!(txt instanceof Array)) {
128+
txt = [txt];
129+
}
130+
for (var i = 0; i < txt.length; i++) {
131+
var currentLine = txt[i];
132+
var textSize = this.getStringUnitWidth(currentLine) * this.internal.getFontSize();
133+
this.text(currentLine, x + w - textSize - padding, y + this.internal.getLineHeight()*(i+1));
133134
}
134135
} else {
135136
this.text(txt, x + padding, y + this.internal.getLineHeight());

0 commit comments

Comments
 (0)