Skip to content

Commit 3f00be1

Browse files
committed
jspdf.plugin.cell.js :
- Fixed jsPDFAPI.getTextDimensions
1 parent ee2c820 commit 3f00be1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

jspdf.plugin.cell.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,21 @@
6060
fontSize = this.internal.getFontSize();
6161
fontStyle = this.internal.getFont().fontStyle;
6262

63-
var px2pt = 1.545454545454545454545454,
63+
// 1 pixel = 0.264583 mm and 1 mm = 72/25.4 point
64+
var px2pt = 0.264583 * 72 / 25.4,
6465
dimensions,
6566
text;
6667

6768
text = document.createElement('font');
6869
text.id = "jsPDFCell";
69-
// error text.style = "font-family: ' + fontName + ';font-size:' + fontSize + 'pt;font-style: ' + fontStyle + ';";
70+
text.style.fontStyle = fontStyle;
71+
text.style.fontName = fontName;
72+
text.style.fontSize = fontSize + 'pt';
7073
text.innerText = txt;
7174

7275
document.body.appendChild(text);
7376

74-
dimensions = { w: text.offsetWidth / px2pt, h: text.offsetHeight / px2pt};
77+
dimensions = { w: (text.offsetWidth + 1) * px2pt, h: (text.offsetHeight + 1) * px2pt};
7578

7679
document.body.removeChild(text);
7780

0 commit comments

Comments
 (0)