Provide values for px, pc, em, ex and utilize switch for divisor determination in jsPDF in order to utilize the user's current base unit type in PDF exports. Accurate conversion formulas?

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2797 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Brett Zamir 2014-04-08 11:01:46 +00:00
parent 667de19147
commit b1ea39db46
2 changed files with 29 additions and 11 deletions

View File

@ -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

View File

@ -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/*,