Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将ASP.NET内容导出到图像_Asp.net_Image_Export - Fatal编程技术网

将ASP.NET内容导出到图像

将ASP.NET内容导出到图像,asp.net,image,export,Asp.net,Image,Export,有人知道有什么工具可以将HTML控件的内容(假定为div)导出为几种不同的图像格式之一(jpg、png和bmp就足够了)?我希望渲染是在服务器端完成的(GDI很好),只需创建一个图像,我可以使用HttpHandler返回它,因此如果可能的话,它不需要保存。我知道很多报告工具(SSR、Telerik reporting)都提供了导出到图像的选项,但我不知道它们是如何做到的。你可以在服务器端启动IE或其他浏览器,并使用GDI截图,但要精确定位特定的div需要更多的工作 如果您需要客户端屏幕截图,则需

有人知道有什么工具可以将HTML控件的内容(假定为div)导出为几种不同的图像格式之一(jpg、png和bmp就足够了)?我希望渲染是在服务器端完成的(GDI很好),只需创建一个图像,我可以使用HttpHandler返回它,因此如果可能的话,它不需要保存。我知道很多报告工具(SSR、Telerik reporting)都提供了导出到图像的选项,但我不知道它们是如何做到的。

你可以在服务器端启动IE或其他浏览器,并使用GDI截图,但要精确定位特定的div需要更多的工作

如果您需要客户端屏幕截图,则需要使用Java或类似工具


也可能有帮助。

如果你想拍摄网页截图并将其保存为图像格式(无论你想要什么) 你可以这样做

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Web.Services;
using System.Text;
using System.Windows.Forms;//must be included for capturing screenshot

public partial class capture_webpage_screenshot : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
        Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
        graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
        bitmap.Save(@"c:\screenshot\myscreenshot.bmp", ImageFormat.Bmp);

    }
}
您必须遵循以下步骤:

只需执行以下步骤

  • 右键单击项目名称
  • 添加引用->.net选项卡,然后选择system.windows.forms 然后按ok按钮
  • 在.aspx代码隐藏文件中,您必须导入 System.Windows.Formsnamespace,仅此而已
通过自定义CopyFromScreen()函数中使用的参数,您可以了解如何捕获屏幕的一小部分(如果需要)

创建一个文件夹并用c代码给出文件夹路径,就像上面我给出的一样。您还可以自定义代码,并在每次生成位图文件时提供位图文件的动态名称


我希望它能帮助你……

我认为这个选项最有效,但在使用这个应用程序时,我意识到我需要更多的定制,而像这样进行真正的屏幕截图并不是最好的方式。我决定在GDI中绘制图像,虽然很麻烦,但它将为我的整个场景提供最佳的灵活性。谢谢你的提示!