diff --git a/editor/jspdf/jspdf.js b/editor/jspdf/jspdf.js index de45a91c..e50eb857 100644 --- a/editor/jspdf/jspdf.js +++ b/editor/jspdf/jspdf.js @@ -990,16 +990,33 @@ PubSub implementation // @TODO: Add different output options }; - if (unit === 'pt') { - k = 1; - } else if (unit === 'mm') { - k = 72 / 25.4; - } else if (unit === 'cm') { - k = 72 / 2.54; - } else if (unit === 'in') { - k = 72; - } else { - throw ('Invalid unit: ' + unit); + switch (unit) { + case 'pt': + k = 1; + break; + case 'mm': + k = 72 / 25.4; + break; + case 'cm': + k = 72 / 2.54; + break; + case 'in': + k = 72; + break; + case 'px': + k = 96 / 72; + break; + case 'pc': + k = 12; + break; + case 'em': + k = 12; + break; + case 'ex': + k = 6; + break; + default: + throw ('Invalid unit: ' + unit); } // Dimensions are stored as user units and converted to points on output diff --git a/editor/svg-editor.js b/editor/svg-editor.js index a320cf05..8d5ff181 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1111,7 +1111,8 @@ TODOS if (type === 'PDF') { var res = svgCanvas.getResolution(); var orientation = res.w > res.h ? 'landscape' : 'portrait'; - var doc = new jsPDF(orientation, 'pt', [res.w, res.h]); // Todo: Give options to use predefined jsPDF formats like "a4", etc. from pull-down (with option to keep customizable) + var units = curConfig.baseUnit; + var doc = new jsPDF(orientation, units, [res.w, res.h]); // Todo: Give options to use predefined jsPDF formats like "a4", etc. from pull-down (with option to keep customizable) var docTitle = svgCanvas.getDocumentTitle(); doc.setProperties({ title: docTitle/*,