Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6953801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:31:30+00:00 2026-05-27T14:31:30+00:00

Hello I managed to use the class ClassWSThumb (you can find it here http://www.codeproject.com/KB/aspnet/Website_URL_Screenshot.aspx

  • 0

Hello I managed to use the class ClassWSThumb (you can find it here http://www.codeproject.com/KB/aspnet/Website_URL_Screenshot.aspx) in order to get screenshoots from webpages.
Here is the class file:

Imports System.Drawing
Imports System.Windows.Forms
Imports System.Threading
Imports System.IO

Namespace GetWebSiteThumb
    Public Class ClassWSThumb
        Public Shared Function GetWebSiteThumbnail(ByVal Url As String, ByVal BrowserWidth As Integer, ByVal BrowserHeight As Integer, ByVal ThumbnailWidth As Integer, ByVal ThumbnailHeight As Integer) As Bitmap
            Return New WSThumb(Url, BrowserWidth, BrowserHeight, ThumbnailWidth, ThumbnailHeight).GetWSThumb()
        End Function

        Private Class WSThumb
            Public Sub New(ByVal Url As String, ByVal BW As Integer, ByVal BH As Integer, ByVal TW As Integer, ByVal TH As Integer)
                __Url = Url
                __BrowserWidth = BW
                __BrowserHeight = BH
                __ThumbnailWidth = TW
                __ThumbnailHeight = TH
            End Sub

            Private __Bitmap As Bitmap = Nothing
            Private __Url As String = Nothing
            Private __ThumbnailWidth As Integer
            Private __ThumbnailHeight As Integer
            Private __BrowserWidth As Integer
            Private __BrowserHeight As Integer

            Public Property Url() As String
                Get
                    Return __Url
                End Get
                Set(ByVal value As String)
                    __Url = value
                End Set
            End Property

            Public ReadOnly Property ThumbnailImage() As Bitmap
                Get
                    Return __Bitmap
                End Get
            End Property

            Public Property ThumbnailWidth() As Integer
                Get
                    Return __ThumbnailWidth
                End Get
                Set(ByVal value As Integer)
                    __ThumbnailWidth = value
                End Set
            End Property

            Public Property ThumbnailHeight() As Integer
                Get
                    Return __ThumbnailHeight
                End Get
                Set(ByVal value As Integer)
                    __ThumbnailHeight = value
                End Set
            End Property

            Public Property BrowserWidth() As Integer
                Get
                    Return __BrowserWidth
                End Get
                Set(ByVal value As Integer)
                    __BrowserWidth = value
                End Set
            End Property

            Public Property BrowserHeight() As Integer
                Get
                    Return __BrowserHeight
                End Get
                Set(ByVal value As Integer)
                    __BrowserHeight = value
                End Set
            End Property

            Public Function GetWSThumb() As Bitmap
                Dim __threadStart As New ThreadStart(AddressOf _GenerateWSThumb)
                Dim __thread As New Thread(__threadStart)

                __thread.SetApartmentState(ApartmentState.STA)
                __thread.Start()
                __thread.Join()
                Return __Bitmap
            End Function

            Private Sub _GenerateWSThumb()
                Dim __WebBrowser As New WebBrowser()
                __WebBrowser.ScrollBarsEnabled = False
                __WebBrowser.Navigate(__Url)
                AddHandler __WebBrowser.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf WebBrowser_DocumentCompleted)
                While __WebBrowser.ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                End While
                __WebBrowser.Dispose()
            End Sub

            Private Sub WebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
                Dim __WebBrowser As WebBrowser = DirectCast(sender, WebBrowser)
                __WebBrowser.ClientSize = New Size(Me.__BrowserWidth, Me.__BrowserHeight)
                __WebBrowser.ScrollBarsEnabled = False
                __Bitmap = New Bitmap(__WebBrowser.Bounds.Width, __WebBrowser.Bounds.Height)
                __WebBrowser.BringToFront()
                __WebBrowser.DrawToBitmap(__Bitmap, __WebBrowser.Bounds)

                If __ThumbnailHeight <> 0 AndAlso __ThumbnailWidth <> 0 Then
                    __Bitmap = DirectCast(__Bitmap.GetThumbnailImage(__ThumbnailWidth, __ThumbnailHeight, Nothing, IntPtr.Zero), Bitmap)
                End If
            End Sub
        End Class
    End Class
End Namespace

and here is the implementation

    Protected Sub btnExportToIMG_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportToIMG.Click
        'This Code Exports to Image 
        StartDuration()        
        Dim url As String = "http://somepage"

        '//example as a Class Method
        Dim bmp As Bitmap = ClassWSThumb.GetWebSiteThumbnail(url, Int32.Parse(800), Int32.Parse(600), Int32.Parse(800), Int32.Parse(600))
        bmp.Save(Server.MapPath("~") + "/exportedpdf/thumbnail.bmp")
        Image1.ImageUrl = "~/thumbnail.bmp"
        Image1.Width = 800
        Image1.Height = 600
        StopDuration()


    End Sub
End Class

Everything seems to be working perfectly, but i bumped into a situation were i dont know how to handle.
If the target website has some ajax information that needs to be loaded after the ready state, i get a screenshoot of the page with no data, because the data was not loaded yet.

any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:31:31+00:00Added an answer on May 27, 2026 at 2:31 pm

    Try adding the following at the top of the WebBrowser_DocumentCompleted Sub Routine…

    'Give the Browser 15 seconds to load Ajax data.
    System.Threading.Thread.Sleep(15000)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CODE HERE: http://jsfiddle.net/B7Y43/ Hello fello programmers, I have the following situation: My PHP-script generates
For ease I'll use hello world... public class HelloWorld{ public static void main (String
Hello I've managed to integrate SlimDX and DirectX 11 graphics in a WPF application
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
I've managed to make a typewriter class that does what I want it to
Hello StackOverflow, I have an ASP.NET/C# webpage that calls functions from a managed .dll
Hello i'm trying to use facebook showPermissionDialog to get user datas this is my
I have managed to use SAPI Text-To-Speech in Delphi/Lazarus by using the following code:
With this simple C# code, I run csc hello.cs; ildasm /out=hello.txt hello.exe . class
I really don't understand what the issue is here, I've tried everything I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.