From 9b060a3b48b1fcece89168111cca780274d9cd1d Mon Sep 17 00:00:00 2001 From: Anton Lobovkin Date: Thu, 25 Mar 2021 23:45:08 +0100 Subject: [PATCH] Fix for [#43] document not found. An addition for #48: createCanvas is not enough, need to pass createImage to work with embedded images. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index a183379..6d91e1f 100644 --- a/index.js +++ b/index.js @@ -69,7 +69,7 @@ async function convert(svgContent, options, callback) { var canvas = Canvas.createCanvas(options.width||100, options.height||100); var ctx = canvas.getContext('2d'); try { - const renderer = canvg.Canvg.fromString(ctx, svgContent, { DOMParser: jsdomWindow.DOMParser, window: jsdomWindow, ignoreMouse: true, ignoreAnimation: true, createCanvas: Canvas.createCanvas, ImageClass: Canvas.Image }); + const renderer = canvg.Canvg.fromString(ctx, svgContent, { DOMParser: jsdomWindow.DOMParser, window: jsdomWindow, ignoreMouse: true, ignoreAnimation: true, createCanvas: Canvas.createCanvas, createImage: Canvas.loadImage, ImageClass: Canvas.Image }); await renderer.render(); } catch (error) { callback(error);