File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,11 +59,20 @@ export const cloneNode = function(node, javascriptEnabled) {
5959 return clone ;
6060}
6161
62- // Convert units using the conversion value 'k' from jsPDF.
62+ // Convert units from px using the conversion value 'k' from jsPDF.
6363export const unitConvert = function ( obj , k ) {
64- var newObj = { } ;
65- for ( var key in obj ) {
66- newObj [ key ] = obj [ key ] * 72 / 96 / k ;
64+ if ( objType ( obj ) === 'number' ) {
65+ return obj * 72 / 96 / k ;
66+ } else {
67+ var newObj = { } ;
68+ for ( var key in obj ) {
69+ newObj [ key ] = obj [ key ] * 72 / 96 / k ;
70+ }
71+ return newObj ;
6772 }
68- return newObj ;
6973} ;
74+
75+ // Convert units to px using the conversion value 'k' from jsPDF.
76+ export const toPx = function toPx ( val , k ) {
77+ return Math . floor ( val * k / 72 * 96 ) ;
78+ }
Original file line number Diff line number Diff line change 11import jsPDF from 'jspdf' ;
22import html2canvas from 'html2canvas' ;
3- import { objType , createElement , cloneNode , unitConvert } from './utils.js' ;
3+ import { objType , createElement , cloneNode , toPx } from './utils.js' ;
44
55/* ----- CONSTRUCTOR ----- */
66
@@ -351,10 +351,6 @@ Worker.prototype.setMargin = function setMargin(margin) {
351351}
352352
353353Worker . prototype . setPageSize = function setPageSize ( pageSize ) {
354- function toPx ( val , k ) {
355- return Math . floor ( val * k / 72 * 96 ) ;
356- }
357-
358354 return this . then ( function setPageSize_main ( ) {
359355 // Retrieve page-size based on jsPDF settings, if not explicitly provided.
360356 pageSize = pageSize || jsPDF . getPageSize ( this . opt . jsPDF ) ;
You can’t perform that action at this time.
0 commit comments