Witam
Mam do Was pytanie, potrzebuje zrobić program do przerobienia strony html do pdf
ale mam problem, coś takiego mam:
private void button3_Click(object sender, EventArgs e)
{
Bitmap thumbnail = GenerateScreenshot("www.wp.pl",1300,768);
pictureBox1.Image = thumbnail;
thumbnail.Save("aaa.bmp");
}
public Bitmap GenerateScreenshot(string url)
{
return GenerateScreenshot(url, -1, -1);
}
public Bitmap GenerateScreenshot(string url, int width, int height)
{
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
wb.Width = width;
wb.Height = height;
if (width == -1)
{
wb.Width = wb.Document.Body.ScrollRectangle.Width;
}
if (height == -1)
{
wb.Height = wb.Document.Body.ScrollRectangle.Height;
}
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
return bitmap;
}
Robi mi foto przeglądarki, ale ucina mi zdjecie www w połowie przy generowaniu, bo chce to przez screenshota zrobić, żeby przesłać obraz strony do pdf... wszystko w picturebox sie otwiera :)