diff --git a/examples/canvg_context2d/bar_graph_with_text_and_lines.html b/examples/canvg_context2d/bar_graph_with_text_and_lines.html index d64325f69..e695808f7 100644 --- a/examples/canvg_context2d/bar_graph_with_text_and_lines.html +++ b/examples/canvg_context2d/bar_graph_with_text_and_lines.html @@ -10,9 +10,8 @@ - - - + + @@ -823,13 +822,13 @@

Bar Graph With Text And Lines

}); } - window.onload = function () { - doRefresh(); + window.onload = async () => { + await doRefresh(); }; - var doRefresh = function () { - var makePdf = function () { - var pdf = new jsPDF('p', 'pt', 'c1'); + var doRefresh = async () => { + var makePdf = async () => { + var pdf = new jspdf.jsPDF('p', 'pt', 'c1'); var c = pdf.canvas; c.width = 1000; c.height = 500; @@ -840,16 +839,12 @@

Bar Graph With Text And Lines

ctx.fillRect(0, 0, 1000, 700); //load a svg snippet in the canvas with id = 'drawingArea' - canvg(c, document.getElementById('svg').outerHTML, { - ignoreMouse: true, - ignoreAnimation: true, - ignoreDimensions: true - }); - + const v = await canvg.Canvg.from(ctx, document.getElementById('svg').outerHTML, canvg.presets.offscreen()); + await v.render(); return pdf; }; - document.getElementById('result').setAttribute('src', makePdf().output('dataurlstring')); - document.getElementById('source').innerText = makePdf().output(); + document.getElementById('result').setAttribute('src', (await makePdf()).output('dataurlstring')); + document.getElementById('source').innerText = (await makePdf()).output(); //makePdf().save(); }; diff --git a/examples/canvg_context2d/piechart.html b/examples/canvg_context2d/piechart.html index e68b1b029..df80087c3 100644 --- a/examples/canvg_context2d/piechart.html +++ b/examples/canvg_context2d/piechart.html @@ -10,9 +10,8 @@ - - - + + @@ -57,13 +56,13 @@

Pie-Chart

}); } - window.onload = function () { - doRefresh(); + window.onload = async () => { + await doRefresh(); }; - var doRefresh = function () { - var makePdf = function () { - var pdf = new jsPDF('p', 'pt', 'c1'); + var doRefresh = async () => { + var makePdf = async () => { + var pdf = new jspdf.jsPDF('p', 'pt', 'c1'); var c = pdf.canvas; c.width = 1000; c.height = 500; @@ -74,16 +73,13 @@

Pie-Chart

ctx.fillRect(0, 0, 1000, 700); //load a svg snippet in the canvas with id = 'drawingArea' - canvg(c, document.getElementById('svg').outerHTML, { - ignoreMouse: true, - ignoreAnimation: true, - ignoreDimensions: true - }); + const v = await canvg.Canvg.from(ctx, document.getElementById('svg').outerHTML, canvg.presets.offscreen()); + await v.render(); return pdf; }; - document.getElementById('result').setAttribute('src', makePdf().output('dataurlstring')); - document.getElementById('source').innerText = makePdf().output(); + document.getElementById('result').setAttribute('src', (await makePdf()).output('dataurlstring')); + document.getElementById('source').innerText = (await makePdf()).output(); //makePdf().save(); };