 
             dest = path.resolve(rootDirectoryPath, (Math.random().toString(36).substr(2, 9)) + '_viz.png')
 
-            saveSvgAsPng div.children[0], dest, (error)->
+            svgElement = div.children[0]
+            width = svgElement.getBBox().width
+            height = svgElement.getBBox().height
+
+            saveSvgAsPng svgElement, dest, {width, height}, (error)->
               cb(null, {dest, start, end, content})
 
 


  return processCodes(codes, lines, rootDirectoryPath, callback)

saveSvgAsPng = (svgElement, dest, cb)->
  return cb(null) if !svgElement or svgElement.tagName.toLowerCase() != 'svg'

  width = null #svgElement.offsetWidth
  height = null #svgElement.offsetHeight

  svgAsPngUri svgElement, {}, (data)->
    base64Data = data.replace(/^data:image\/png;base64,/, "")
    fs.writeFile dest, base64Data, 'base64', (err)->
      cb(err)


              dest = path.resolve(rootDirectoryPath, (Math.random().toString(36).substr(2, 9)) + '_puml.png')

              svgElement = div.children[0]
              width = svgElement.getBBox().width
              height = svgElement.getBBox().height

              saveSvgAsPng div.children[0], dest, {width, height}, (error)->
                cb(null, {dest, start, end, content})

        asyncFunc = helper(start, end, content)
