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-75d572ba1dddmaster
parent
667de19147
commit
b1ea39db46
|
@ -990,16 +990,33 @@ PubSub implementation
|
||||||
// @TODO: Add different output options
|
// @TODO: Add different output options
|
||||||
};
|
};
|
||||||
|
|
||||||
if (unit === 'pt') {
|
switch (unit) {
|
||||||
k = 1;
|
case 'pt':
|
||||||
} else if (unit === 'mm') {
|
k = 1;
|
||||||
k = 72 / 25.4;
|
break;
|
||||||
} else if (unit === 'cm') {
|
case 'mm':
|
||||||
k = 72 / 2.54;
|
k = 72 / 25.4;
|
||||||
} else if (unit === 'in') {
|
break;
|
||||||
k = 72;
|
case 'cm':
|
||||||
} else {
|
k = 72 / 2.54;
|
||||||
throw ('Invalid unit: ' + unit);
|
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
|
// Dimensions are stored as user units and converted to points on output
|
||||||
|
|
|
@ -1111,7 +1111,8 @@ TODOS
|
||||||
if (type === 'PDF') {
|
if (type === 'PDF') {
|
||||||
var res = svgCanvas.getResolution();
|
var res = svgCanvas.getResolution();
|
||||||
var orientation = res.w > res.h ? 'landscape' : 'portrait';
|
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();
|
var docTitle = svgCanvas.getDocumentTitle();
|
||||||
doc.setProperties({
|
doc.setProperties({
|
||||||
title: docTitle/*,
|
title: docTitle/*,
|
||||||
|
|
Loading…
Reference in New Issue