Merge pull request #4649 from tsiegleauq/pdf-font-size-parsing

use ParseInt in PDF generation
This commit is contained in:
Emanuel Schütze 2019-04-29 19:54:18 +02:00 committed by GitHub
commit bccd9db076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -328,7 +328,7 @@ export class HtmlToPdfService {
if (nodeName === 'ol') { if (nodeName === 'ol') {
const start = element.getAttribute('start'); const start = element.getAttribute('start');
if (start) { if (start) {
list.start = +start; list.start = parseInt(start, 10);
} }
} }
@ -579,7 +579,7 @@ export class HtmlToPdfService {
element.getAttribute('class') && element.getAttribute('class') &&
element.getAttribute('class').indexOf('os-line-number') > -1 element.getAttribute('class').indexOf('os-line-number') > -1
) { ) {
return +element.getAttribute('data-line-number'); return parseInt(element.getAttribute('data-line-number'), 10);
} }
} }
@ -603,11 +603,11 @@ export class HtmlToPdfService {
if (styleDefinition.length === 2) { if (styleDefinition.length === 2) {
switch (key) { switch (key) {
case 'padding-left': { case 'padding-left': {
styleObject.margin = [+value, 0, 0, 0]; styleObject.margin = [parseInt(value, 10), 0, 0, 0];
break; break;
} }
case 'font-size': { case 'font-size': {
styleObject.fontSize = +value; styleObject.fontSize = parseInt(value, 10);
break; break;
} }
case 'text-align': { case 'text-align': {
@ -688,7 +688,7 @@ export class HtmlToPdfService {
} else if (rgbRegex.test(color)) { } else if (rgbRegex.test(color)) {
const decimalColors = rgbRegex.exec(color).slice(1); const decimalColors = rgbRegex.exec(color).slice(1);
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
let decimalValue = +decimalColors[i]; let decimalValue = parseInt(decimalColors[i], 10);
if (decimalValue > 255) { if (decimalValue > 255) {
decimalValue = 255; decimalValue = 255;
} }