using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace pdf
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length > 0)
{
webBrowser1.Navigate(textBox1.Text);
}
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if(webBrowser1.ReadyState!=WebBrowserReadyState.Complete)
{
return;
}
HtmlDocument doc = webBrowser1.Document;
int height = Convert.ToInt32(doc.Body.GetAttribute("scrollHeight")) + 10;
int width = Convert.ToInt32(doc.Body.GetAttribute("scrollWidth")) + 10;
webBrowser1.Height = height;
webBrowser1.Width = width;
Bitmap bmp = new Bitmap(width, height);
Rectangle rec = new Rectangle();
rec.Width = width;
rec.Height = height;
webBrowser1.DrawToBitmap(bmp, rec);
bmp.Save("d:\\testIta.jpg");
bmp.Dispose();
}
}
}
c#截图
最新推荐文章于 2024-09-28 17:59:54 发布
1395

被折叠的 条评论
为什么被折叠?



