当前位置:网站首页>C # save web pages as pictures (using WebBrowser)
C # save web pages as pictures (using WebBrowser)
2022-07-02 08:45:00 【Qingshan blog】
using System;
using System.Drawing;
using System.Windows.Forms;
namespace UrlToImage
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var browser = new WebBrowser {ScrollBarsEnabled = false, ScriptErrorsSuppressed = true};
browser.Navigate("http://www.rc114.com/");
browser.DocumentCompleted += webBrowser_DocumentCompleted;
}
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var browser = (WebBrowser) sender;
if (browser.ReadyState == WebBrowserReadyState.Complete)
{
if (browser.Document != null)
{
if (browser.Document.Body != null)
{
var height = browser.Document.Body.ScrollRectangle.Height;
var width = browser.Document.Body.ScrollRectangle.Width;
browser.Height = height;
browser.Width = width;
using (var bitmap = new Bitmap(width, height))
{
var rectangle = new Rectangle(0, 0, width, height);
browser.DrawToBitmap(bitmap, rectangle);
var dialog = new SaveFileDialog();
dialog.Filter = " JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png ";
dialog.ShowDialog();
bitmap.Save(dialog.FileName);
}
}
}
}
}
}
}
边栏推荐
- Googlenet network explanation and model building
- Minecraft air Island service
- Web技术发展史
- 队列的基本概念介绍以及典型应用示例
- 使用wireshark抓取Tcp三次握手
- PCL calculates the intersection of three mutually nonparallel planes
- Aneng logistics' share price hit a new low: the market value evaporated by nearly 10 billion yuan, and it's useless for chairman Wang Yongjun to increase his holdings
- 将一串数字顺序后移
- idea中注释代码取消代码的快捷键
- Nacos 下载启动、配置 MySQL 数据库
猜你喜欢

将一串数字顺序后移

HCIA - application layer

sqli-labs第12关

What is SQL injection

Sentinel 简单使用

Nacos download, start and configure MySQL database
![[blackmail virus data recovery] suffix Rook3 blackmail virus](/img/46/debc848d17767d021f3f41924cccfe.jpg)
[blackmail virus data recovery] suffix Rook3 blackmail virus

C language custom types - structure, bit segment (anonymous structure, self reference of structure, memory alignment of structure)

Minecraft空岛服开服

HCIA—应用层
随机推荐
D interface and domain problems
OpenFeign 简单使用
web安全--逻辑越权
Routing foundation - dynamic routing
Synchronize files using unison
Use the numbers 5, 5, 5, 1 to perform four operations. Each number should be used only once, and the operation result value is required to be 24
旋转链表(图解说明)
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
STM32 new project (refer to punctual atom)
一个经典约瑟夫问题的分析与解答
选择排序和插入排序
HCIA—数据链路层
Qunhui NAS configuring iSCSI storage
Introduction to anti interception technology of wechat domain name
Application of kotlin - higher order function
Network security - summary and thinking of easy-to-use fuzzy tester
Learning C
ICMP协议
Use the kaggle training model and download your own training model
Kubedm deploys kubernetes v1.23.5 cluster