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-04-16 10:17:52 发布