title: Convert SVG to PNG and maintain CSS integrity
body: <p>I am currently using canvg() and Canvas2Image to copy my SVG to a canvas and then convert the canvas to PNG. I would like to maintain the image format and not use PDF.</p>
  
  <p>How can I maintain the CSS integrity? Chart is made using NVD3.js.</p>
  
  <pre><code>downloadPhoto: function() {
    var chartArea = document.getElementsByTagName('svg')[0].parentNode;
    var svg = chartArea.innerHTML;
    var canvas = document.createElement('canvas');
    canvas.setAttribute('width', chartArea.offsetWidth);
    canvas.setAttribute('height', chartArea.offsetHeight);
    canvas.setAttribute('display', 'none');
  
    canvas.setAttribute(
      'style',
      'position: absolute; ' +
      'top: ' + (-chartArea.offsetHeight * 2) + 'px;' +
      'left: ' + (-chartArea.offsetWidth * 2) + 'px;');
    document.body.appendChild(canvas);
    canvg(canvas, svg);
    Canvas2Image.saveAsPNG(canvas);
    canvas.parentNode.removeChild(canvas);
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/z3a1Y.png" alt="Original SVG"></p>
  
  <p><img src="https://i.stack.imgur.com/Rxk5O.png" alt="SVG converted to PNG"></p>