Skip to content

Commit 7ada5fd

Browse files
committed
[DASH-49] Create Export to PDF
Removed reliance on jQuery
1 parent 55e0d22 commit 7ada5fd

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

jspdf.plugin.cell.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,29 @@
5353
fontName = this.internal.getFont().fontName;
5454
fontSize = this.internal.getFontSize();
5555
fontStyle = this.internal.getFont().fontStyle;
56-
var px2pt = 1.545454545454545454545454, text = $('<font id="jsPDFCell" style="font-family: ' + fontName + ';font-size:' + fontSize + 'pt;font-style: ' + fontStyle + ';" hidden>' + txt + '</font>').appendTo('body'),
57-
dimentions = { w: text.width() / px2pt, h: text.height() / px2pt};
58-
text.remove();
59-
return dimentions;
56+
var px2pt = 1.545454545454545454545454,
57+
dimensions,
58+
text;
59+
60+
text = document.createElement('font');
61+
text.id = "jsPDFCell";
62+
text.style = "font-family: ' + fontName + ';font-size:' + fontSize + 'pt;font-style: ' + fontStyle + ';";
63+
text.innerText = txt;
64+
65+
document.body.appendChild(text);
66+
67+
dimensions = { w: text.offsetWidth / px2pt, h: text.offsetHeight / px2pt};
68+
69+
document.body.removeChild(text);
70+
71+
return dimensions;
6072
};
61-
73+
6274
jsPDFAPI.cellAddPage = function () {
6375
this.addPage();
6476
pages += 1;
6577
};
66-
78+
6779
jsPDFAPI.cellInitialize = function () {
6880
maxLn = 0;
6981
lastCellPos = { x: undefined, y: undefined, w: undefined, h: undefined, ln: undefined };

0 commit comments

Comments
 (0)