如何使包含HTML到C#的图像的字符串? [英] How to render a string containing HTML into an image in C#?

查看:85
本文介绍了如何使包含HTML到C#的图像的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个具有为用户的互动反馈工具的Web应用程序。在此应用的用户可以点击发送反馈按钮。按钮架起覆盖在他们的当前网页,并允许他们拖到高亮区域 DIV s到强调某些区域。一旦他们提交他们的反馈整个页面的HTML通过AJAX传递回服务器。

I am developing a web application that has an interactive feedback tool for users. In this application users can click a send feedback button. The button puts up an overlay over their current web page and allows them to drag highlight area DIVs to emphasize certain areas. Once they submit their feedback the HTML of the entire page is passed via AJAX back to the server.

在服务器上我现在有一个包含页面的HTML字符串。在这里,我想运行通过某种引擎呈现HTML和构建一个图像此字符串。 A排序四围如果你愿意采取截图的方式。

Once on the server I now have a string containing the HTML of the page. From here I would like to run this string through some sort of engine that renders the HTML and builds an image. A sort of round about way of taking a screenshot if you will.

一个人怎么可能做到这样呢? ?是否有可用的引擎是用C#编写,并可以建立HTML和渲染图像

How might one accomplish something like this? Are there engines available that are written in C# and can build up the HTML and render an image?

推荐答案

看看这个框架 - http://awesomium.com/

这正是你所需要的。

设置基本URL,这将是需要解决任何相对网址

Set the base URL, this will be needed to resolve any relative URLs

WebCore.SetBaseDirectory("C:\\MyApplication\\MyBaseDirectory");



然后加载HTML -

Then load the HTML -

myWebView.LoadHTML("<p>Hello World!</p>");



然后使用.Render()方法,你就可以呈现的内容保存到图像。

Then use the .Render() method, and you'll be able to save the rendered content to an image.

这篇关于如何使包含HTML到C#的图像的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆