【发布时间】:2015-05-01 02:30:16
【问题描述】:
我正在尝试将我的 WebKitBrowser DocumentText 设置为包含本地 SVG 文件路径作为图像源的 HTML 字符串。 实际上我想在网络浏览器中显示 SVG 文件。 这是我的代码:
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;
当我运行代码时,浏览器只显示图像画布,不渲染 SVG 文件。我也用 JPG 图像尝试过,得到了相同的结果。
谁能告诉我这段代码有什么问题?
【问题讨论】:
标签: c# html image webkit htmltextwriter