Fixing PDF in IE11 (fixes #3206, fixes #3217)

This commit is contained in:
FinnStutzenstein 2017-04-28 12:13:20 +02:00
parent c7c7bfca9c
commit 239d56f350
2 changed files with 38 additions and 2 deletions

View File

@ -45,6 +45,7 @@ Core:
General: General:
- Several bugfixes and minor improvements. - Several bugfixes and minor improvements.
- Bugfixes for PDF creation [#3227]
Version 2.1.1 (2017-04-05) Version 2.1.1 (2017-04-05)

View File

@ -476,6 +476,37 @@ angular.module('OpenSlidesApp.core.pdf', [])
} }
return currentParagraph; return currentParagraph;
}, },
/**
* Returns the color in a hex format (e.g. #12ff00).
* Tries to convert the rgb form into this.
* @function
* @param {string} color
*/
parseColor = function (color) {
var hexRegex = new RegExp('^#([0-9a-f]{3}|[0-9a-f]{6})$');
// e.g. #fff or #ff0048
var rgbRegex = new RegExp('^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$');
// e.g. rgb(0,255,34) or rgb(22, 0, 0)
if (hexRegex.test(color)) {
return color;
} else if(rgbRegex.test(color)) {
var decimalColors = rgbRegex.exec(color).slice(1);
for (var i = 0; i < 3; i++) {
var decimalValue = parseInt(decimalColors[i]);
if (decimalValue > 255) {
decimalValue = 255;
}
var hexString = '0' + decimalValue.toString(16);
hexString = hexString.slice(-2);
decimalColors[i] = hexString;
}
return '#' + decimalColors.join('');
} else {
console.err('Could not parse color "' + color + '"');
return color;
}
},
/** /**
* Extracts the style from an object * Extracts the style from an object
* @function * @function
@ -529,7 +560,7 @@ angular.module('OpenSlidesApp.core.pdf', [])
} }
break; break;
case "color": case "color":
o.color = value; o.color = parseColor(value);
break; break;
case "background-color": case "background-color":
o.background = value; o.background = value;
@ -724,8 +755,12 @@ angular.module('OpenSlidesApp.core.pdf', [])
break; break;
} else { } else {
currentParagraph = create("text"); currentParagraph = create("text");
currentParagraph.lineHeight = 1.25; if (lineNumberMode == "none") {
currentParagraph.margin = [0, 0, 0, 0];
} else {
currentParagraph.margin = [20, 0, 0, 0]; currentParagraph.margin = [20, 0, 0, 0];
}
currentParagraph.lineHeight = 1.25;
alreadyConverted.push(currentParagraph); alreadyConverted.push(currentParagraph);
} }
break; break;