This project is read-only.
1
Vote

svgDocument.Draw fails always

description

Hello, I am trying to convert an SVG to a bitmap object all through streaming in a vb.net 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=""http://www.w3.org/2000/svg""" _
                    + " xmlns:xlink=""http://www.w3.org/1999/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>"

            xmldoc.LoadXml(strSVG)
            'xmldoc.Load(msOrigSvg)

            Dim svgDocument As New SvgDocument
            svgDocument.Open(xmldoc)

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

            Dim tmpBitmap As New System.Drawing.Bitmap(wdth, hght,
                                                       System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            svgDocument.Draw(tmpBitmap)
            'Dim tmpBitmap As System.Drawing.Bitmap = svgDocument.Draw()

comments

luisfurr wrote Apr 22, 2015 at 12:54 AM

I used NuGet to get your version 2.0.0 and this would be the ideal solution if I could get it to work.
Thanks

luisfurr wrote Apr 22, 2015 at 8:44 PM

Never Mind - I found the problem - nothing new to add to this thread.