Letstertjof
New Member
I am trying to convert web page into .jpg image in asp.net using c#. My code is here.\[code\]public Bitmap Generate() { // Thread var m_thread = new Thread(_Generate); m_thread.SetApartmentState(ApartmentState.STA); m_thread.Start(); m_thread.Join(); return m_Bitmap; }private void _Generate() { var browser = new WebBrowser { ScrollBarsEnabled = false }; browser.Navigate(m_Url); browser.DocumentCompleted += WebBrowser_DocumentCompleted; while (browser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } browser.Dispose(); }private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { // Capture var browser = (WebBrowser)sender; browser.ClientSize = new Size(browser.Document.Body.ScrollRectangle.Width, browser.Document.Body.ScrollRectangle.Bottom); browser.ScrollBarsEnabled = false; m_Bitmap = new Bitmap(browser.Document.Body.ScrollRectangle.Width, browser.Document.Body.ScrollRectangle.Bottom); browser.BringToFront(); browser.DrawToBitmap(m_Bitmap, browser.Bounds); }\[/code\]Calling with:\[code\]WebsiteToImage websiteToImage = new WebsiteToImage("http://localhost:60157/abc/xyz.aspx",Server.MapPath("~/Downloads/test.jpg")); websiteToImage.Generate();\[/code\]Here with this code I am not getting complete image of this page. I am getting just left portion. on the place xyz.aspx if I try with google.com I am getting complete image. and if I try with yahoo.com then again same problem. xyz.aspx is complete error free page and it is working fine. but I am unable to get get it's complete image. Please help me ASAP.