From 7ef00d4169c4bc931d01592f431da2af79eb8eb1 Mon Sep 17 00:00:00 2001 From: shivanshi0526 Date: Tue, 23 Jan 2024 15:33:04 +0530 Subject: [PATCH 1/4] update dom to image to pgn --- src/dom-to-image.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dom-to-image.js b/src/dom-to-image.js index 27201ac9..b9d057b5 100644 --- a/src/dom-to-image.js +++ b/src/dom-to-image.js @@ -50,14 +50,14 @@ * @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url * @return {Promise} - A promise that is fulfilled with a SVG image data URL * */ - function toSvg(node, options) { + function toSvg(node, options, loadfonts) { options = options || {}; copyOptions(options); return Promise.resolve(node) .then(function (node) { return cloneNode(node, options.filter, true); }) - .then(embedFonts) + .then(loadfonts && embedFonts) .then(inlineImages) .then(applyOptions) .then(function (clone) { @@ -104,8 +104,8 @@ * @param {Object} options - Rendering options, @see {@link toSvg} * @return {Promise} - A promise that is fulfilled with a PNG image data URL * */ - function toPng(node, options) { - return draw(node, options || {}) + function toPng(node, options, loadfonts) { + return draw(node, options || {}, loadfonts || true) .then(function (canvas) { return canvas.toDataURL(); }); @@ -149,8 +149,8 @@ } } - function draw(domNode, options) { - return toSvg(domNode, options) + function draw(domNode, options, loadfonts) { + return toSvg(domNode, options, loadfonts) .then(util.makeImage) .then(util.delay(100)) .then(function (image) { From 46404c629d981ba62a225b097a564b167cfee413 Mon Sep 17 00:00:00 2001 From: shivanshi0526 Date: Tue, 23 Jan 2024 15:52:29 +0530 Subject: [PATCH 2/4] update draw function --- src/dom-to-image.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dom-to-image.js b/src/dom-to-image.js index b9d057b5..cbc074a4 100644 --- a/src/dom-to-image.js +++ b/src/dom-to-image.js @@ -88,7 +88,7 @@ * @return {Promise} - A promise that is fulfilled with a Uint8Array containing RGBA pixel data. * */ function toPixelData(node, options) { - return draw(node, options || {}) + return draw(node, options || {},loadfonts || true) .then(function (canvas) { return canvas.getContext('2d').getImageData( 0, @@ -118,7 +118,7 @@ * */ function toJpeg(node, options) { options = options || {}; - return draw(node, options) + return draw(node, options,loadfonts || true) .then(function (canvas) { return canvas.toDataURL('image/jpeg', options.quality || 1.0); }); @@ -130,7 +130,7 @@ * @return {Promise} - A promise that is fulfilled with a PNG image blob * */ function toBlob(node, options) { - return draw(node, options || {}) + return draw(node, options || {},loadfonts || true) .then(util.canvasToBlob); } From 3d71e0a185d16b7d6aa5546891189c76766255e6 Mon Sep 17 00:00:00 2001 From: shivanshi0526 Date: Wed, 6 Mar 2024 12:30:22 +0530 Subject: [PATCH 3/4] added console --- src/dom-to-image.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dom-to-image.js b/src/dom-to-image.js index cbc074a4..8cc39f78 100644 --- a/src/dom-to-image.js +++ b/src/dom-to-image.js @@ -150,6 +150,7 @@ } function draw(domNode, options, loadfonts) { + console.log(domNode,"DOM TO IMAGE DRAW DOMNODE") return toSvg(domNode, options, loadfonts) .then(util.makeImage) .then(util.delay(100)) From 73f3fbcaeab5959d27f2fc6277efb2e9acfb178c Mon Sep 17 00:00:00 2001 From: shivanshi0526 Date: Wed, 6 Mar 2024 15:35:49 +0530 Subject: [PATCH 4/4] remove console --- src/dom-to-image.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dom-to-image.js b/src/dom-to-image.js index 8cc39f78..cbc074a4 100644 --- a/src/dom-to-image.js +++ b/src/dom-to-image.js @@ -150,7 +150,6 @@ } function draw(domNode, options, loadfonts) { - console.log(domNode,"DOM TO IMAGE DRAW DOMNODE") return toSvg(domNode, options, loadfonts) .then(util.makeImage) .then(util.delay(100))