Skip to content

Commit c9c84c7

Browse files
committed
Merge pull request #231 from brettz9/patch-1
Allow for other units
2 parents c4dfe00 + a139934 commit c9c84c7

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

jspdf.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -788,16 +788,17 @@ var jsPDF = (function(global) {
788788
// @TODO: Add different output options
789789
});
790790

791-
if (unit === 'pt') {
792-
k = 1;
793-
} else if (unit === 'mm') {
794-
k = 72 / 25.4;
795-
} else if (unit === 'cm') {
796-
k = 72 / 2.54;
797-
} else if (unit === 'in') {
798-
k = 72;
799-
} else {
800-
throw('Invalid unit: ' + unit);
791+
switch (unit) {
792+
case 'pt': k = 1; break;
793+
case 'mm': k = 72 / 25.4; break;
794+
case 'cm': k = 72 / 2.54; break;
795+
case 'in': k = 72; break;
796+
case 'px': k = 96 / 72; break;
797+
case 'pc': k = 12; break;
798+
case 'em': k = 12; break;
799+
case 'ex': k = 6; break;
800+
default:
801+
throw ('Invalid unit: ' + unit);
801802
}
802803

803804
// Dimensions are stored as user units and converted to points on output

0 commit comments

Comments
 (0)