This project is read-only.

svgDocument.Draw always fails

Apr 22, 2015 at 1:09 AM

Hello, I am trying to convert an SVG to a bitmap object all through streaming in a VS2010 web project targeting DOT.NET 4 with the following code, however, I noticed that no matter how simple the SVG is, the svgDocument.GetDimensions().Width and Height always returns 0 (zero). I have inspected to make sure that the xmldoc.innerXml property does in fact contain the SVG xml content. No matter how I load the SVG using svgDocument.Open() its always the same result: width and height are zero and the .Draw() call fails with a bad parameter exception. Please help - I have tried every permutation but I must be missing something... here is my code...

        Dim xmldoc As New System.Xml.XmlDocument
        Dim strSVG As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" _
                + "<svg xmlns=""""" _
                + " xmlns:xlink="""" version=""1.1""" _
                + " width=""100"" height=""100"" viewBox=""0 0 100 100"">" _
                + " <rect x=""10"" y=""10"" height=""100"" width=""100""" _
                + "  style=""stroke:#ff0000; fill: #0000ff""/>" _
                + "</svg>"


        Dim svgDocument As New SvgDocument

        Dim wdth As Integer = svgDocument.GetDimensions().Width
        Dim hght As Integer = svgDocument.GetDimensions().Height

        Dim tmpBitmap As New System.Drawing.Bitmap(wdth, hght,

'Dim tmpBitmap As System.Drawing.Bitmap = svgDocument.Draw()

I got your dll by installing your NuGet Package for version 2.0.0
This would be the ideal solution if I could get it to work. I must be missing something simple.
Apr 22, 2015 at 8:43 PM
Never Mind - I found the problem - nothing new to add to this thread.