Welcome Guest Search | Active Topics | Sign In | Register

SVG2PNG Options
Chris
Posted: Wednesday, July 27, 2016 5:40:06 PM
Rank: Newbie
Groups: Member

Joined: 7/27/2016
Posts: 1
Hi,
I want to convert an SVG into a PNG. I try it this way:

Code: C#
WebView wbView = new WebView();
            wbView.Create(IntPtr.Zero);
            wbView.LoadUrlAndWait(System.IO.Directory.GetCurrentDirectory() + "\\temp.svg");
            System.Drawing.Size s = wbView.GetPageSize();
            wbView.Resize(s.Width, s.Height);
            System.Drawing.Image img = wbView.Capture();
            img.Save(System.IO.Directory.GetCurrentDirectory() + "\\temp.png");


The problem is that GetPageSize does not seem to work with SVG. If I set width and height manually it works fine. Is there a change to improve the resolution via code?
eo_support
Posted: Wednesday, July 27, 2016 6:24:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

Please use the following code:

Code: C#
JSArray size = (JSArray)wbView.EvalScript("var rect = document.rootElement.getBBox();[rect.width, rect.height]");
wbView.Resize((int)size[0], (int)size[1]);


Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.