samedi 28 février 2015

HTML img tag does not render source image in WebKit.NET browser in C#

I'm trying to set my WebKitBrowser DocumentText to an HTML string containing a local SVG file path as image source. Actually I want to show the SVG file in a web browser. Here is my code:



string SVGPath = "file:///D:/MySVGFiles 1/SVGSample01.svg";

StringWriter stringWriter = new StringWriter();

using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
{
writer.AddAttribute(HtmlTextWriterAttribute.Src, SVGPath);
writer.AddAttribute(HtmlTextWriterAttribute.Width, "50%");
writer.AddAttribute(HtmlTextWriterAttribute.Height, "50%");

writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();

}

string content = stringWriter.ToString();

this.webKitBrowser1.DocumentText = content;


When I run the code, the browser only shows the image canvas, and does not render the SVG file. I have tried this with a JPG image too, and got the same result.


Could anyone please tell what is wrong with this code??


Aucun commentaire:

Enregistrer un commentaire