2 Replies - 651 Views - Last Post: 12 March 2018 - 05:23 PM Rate Topic: -----

#1 Remote99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-March 18

Webbrowser screendump with embedded flash

Posted 12 March 2018 - 03:51 PM

Im trying to capture an url to bitmap. The attatched code works great except the included event DocumentCompleted does not detect if an embedded flash objects have finished loading (a drawing in my case).

Any clue to how I could stall the event/thread for the flash to complete the drawing would be appreciated. A fixed value of 2-3sec should do it.

Regards Mark

protected void Capture(object sender, EventArgs e)
{
string url = txtUrl.Text.Trim();
Thread thread = new Thread(delegate()
{
    using (WebBrowser browser = new WebBrowser())
    {
        browser.ScrollBarsEnabled = false;
        browser.AllowNavigation = true;
        browser.Navigate(url);
        browser.Width = 1024;
        browser.Height = 768;
        browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DocumentCompleted);
        while (browser.ReadyState != WebBrowserReadyState.Complete)
        {
            System.Windows.Forms.Application.DoEvents();
        }
    }
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}



private void DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser browser = sender as WebBrowser;
using (Bitmap bitmap = new Bitmap(browser.Width, browser.Height))
{
    browser.DrawToBitmap(bitmap, new Rectangle(0, 0, browser.Width, browser.Height));
    using (MemoryStream stream = new MemoryStream())
    {
        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
        byte[] bytes = stream.ToArray();
        imgScreenShot.Visible = true;
        imgScreenShot.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(bytes);
    }
}
}


Is This A Good Question/Topic? 0
  • +

Replies To: Webbrowser screendump with embedded flash

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,720
  • Joined: 12-June 08

Re: Webbrowser screendump with embedded flash

Posted 12 March 2018 - 04:34 PM

Color me intrigued. Which flash page are you trying to screen capture? Seems odd to be doing that through a website in general.
Was This Post Helpful? 0
  • +
  • -

#3 Remote99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-March 18

Re: Webbrowser screendump with embedded flash

Posted 12 March 2018 - 05:23 PM

The page for capture is an intranet page containing html (which captures just fine) and an embedded flashobject which draws a technical drawing (takes approx 2sec).

My aim is to mirror the intranetpage into a PDF file.
I have no control over the swf source, so I selected the screencapture approach combined with some iTextSharp for pdf'ing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1