title: SVG to PNG - Always broken
body: <p>I have tried so many things but it seems like whatever I do, I cannot successfully convert SVG to PNG</p>
  
  <p>My scenario is the following </p>
  
  <ol>
  <li>Load SVG file from URL into <code>ContentStream</code>    </li>
  <li>Convert it using to PNG using '<a href="https://www.nuget.org/packages/Svg/" rel="nofollow noreferrer">SVG</a>' Nuget package</li>
  <li>Save the PNG to <code>MemoryStream</code></li>
  <li>Upload it to Azure from <code>MemoryStream</code></li>
  </ol>
  
  <p>My code looks like the following (It's pretty straightforward for the most part)</p>
  
  <pre><code>using (HttpClient client = new HttpClient())
  {
      HttpResponseMessage response = await client.GetAsync("https://myweburl/foo.svg");
  
      if (response.IsSuccessStatusCode)
      {
          HttpContent content = response.Content;
          var contentStream = await content.ReadAsStreamAsync();
          var SVG_FILE = SvgDocument.Open&lt;SvgDocument&gt;(contentStream);
          SVG_FILE.ShapeRendering = SvgShapeRendering.Auto;
          var bitmap = SVG_FILE.Draw(200, 200);
          using (var MS = new MemoryStream())
          {
              bitmap.Save(MS, ImageFormat.Png);
              CloudBlockBlob blob = cloudBlobContainer.GetBlockBlobReference("foo.png");
              MS.Seek(0, SeekOrigin.Begin);
              await blob.UploadFromStreamAsync(MS);
              return blob.Name;
          }                        
      }
      else
      {
          throw new FileNotFoundException();
      }
  }
  </code></pre>
  
  <p>I can confirm that the STREAM for SVG is fine but when I convert it to PNG it ends up being all boxes etc </p>
  
  <p><strong>SVG</strong></p>
  
  <p><a href="https://i.stack.imgur.com/dVCUG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dVCUG.png" alt="enter image description here"></a></p>
  
  <p><strong>PNG</strong></p>
  
  <p><a href="https://i.stack.imgur.com/wzEO1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wzEO1.png" alt="enter image description here"></a></p>
  
  <p>I tried different settings in <code>var bitmap = SVG_FILE.Draw(200, 200);</code> such as increasing the height and width and update <code>SvgShapeRendering</code> settings but same results.</p>
  
  <p>Any idea why I am unable to use <code>bitmap.Save</code> to properly render PNG?</p>