Closed psamim closed 7 years ago
In your entry.js you are loading the contents of your svg file and then set the innerHTML of a div to those contents. After that, you are trying to get the svg element with const svgElemnt = div.firstChild;
. This returns a comment element, not the actual svg element. That is because the svg file starts with a XML declaration (<?xml version="1.0"
...), which is converted to a comment when inserted into the DOM via div.innerHTML = ...
.
So instead, retrieve the actual svg element (e.g. with const svgElement = div.querySelector('svg');
), and everything should work.
Hi,
I get the following error:
I have my files at the repo below.
https://github.com/psamim/svg2pdf.js-test
(
npm install
,./node_modules/.bin/webpack ./entry.js bundle.js
, then open index.html)Thanks, Samim