Welcome Guest Search | Active Topics | Sign In | Register

Display SVG in WebBrowser Options
Doru
Posted: Friday, July 29, 2016 6:05:13 AM
Rank: Newbie
Groups: Member

Joined: 7/29/2016
Posts: 2
Hi,

I want to display an svg in a WebBrowser, in WPF.

When I load the svg, only the upper left area of the image is visible in the WebView. This happens even if there's plenty of space to be used by the WebView. I have seen that there's a resize method, but that one can only be used in off screen rendering mode.
Is there a way to View the entire image?

I have isolated my problem to a simple project, with a WebView, and just a call to the LoadHtml() method.

Here's the code sample if it helps: Code Sample

Thanks.

eo_support
Posted: Friday, July 29, 2016 10:16:31 AM
Rank: Administration
Groups: Administration

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

You can either use LoadUrl directly or set the svg size explicitly on the root svg element instead of on the child svg element. The WebView will automatically take the svg size only if the root document is a svg document, which is the case for LoadUrl. When you use LoadHtml, the root document is a HTML document and the svg would be a child element of the root document's body element. When you use it that way, the svg size must be on explicitly specified on the root svg element.

When you use LoadUrl, you can either load the file path directly to the WebView, or you do not actually have a physical file, you can use a custom resource handler to do that. See here for more details:

http://www.essentialobjects.com/doc/webbrowser/advanced/resource_handler.aspx

You can find sample source code for using custom resource handler in our TabbedBrowser sample application.

Please let us know if you still have any questions.

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.