Click here to Skip to main content
15,113,245 members
Articles / Programming Languages / Visual Basic
Posted 5 Aug 2007


122 bookmarked

Capture Entire Web Page

Rate me:
Please Sign up or sign in to vote.
4.56/5 (32 votes)
15 Aug 2007
Capture an entire web page and save it as an image.

Screenshot - gui2_animated.gif


- 08.15.2007 - user defined image formats, save path, base file name, text overlay/watermark, and screen res guidelines... and some other ideas to implement.


I have seen other articles that describe how to accomplish this, but had no luck in getting any to work with Internet Explorer 7. This is a simple example that captures a webpage, inlcuding elements below the fold, and saves it as an image. Here is what to expect:

Screenshot - httpwwwcodeprojectcom.png
Note that this has been resized, captured images are actual size.

Using the code

This example includes only the basics. Images are saved as PNG's in the same directory as the exe. Saving as a different image format, variable pausing, and given filename should be relatively easy to add.

Private Sub GetImage()
    If WebBrowser1.Document Is Nothing Then
    End If
        Dim scrollWidth As Integer
        Dim scrollHeight As Integer
        scrollHeight = WebBrowser1.Document.Body.ScrollRectangle.Height
        scrollWidth = WebBrowser1.Document.Body.ScrollRectangle.Width
        WebBrowser1.Size = New Size(scrollWidth, scrollHeight)
        Dim bm As New Bitmap(scrollWidth, scrollHeight)
        WebBrowser1.DrawToBitmap(bm, New Rectangle(0, 0, bm.Width, bm.Height))
        Dim SaveAsName As String
        SaveAsName = Regex.Replace(textWebURL.Text, "(\\|\/|\:|\*|\?|\""|\<|\>|\|)?", "")
        bm.Save(SaveAsName & ".png", System.Drawing.Imaging.ImageFormat.Png)
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
    buttonCapture.Enabled = True
End Sub

Points of Interest

Waiting a second or two after the document has loaded will allow that much more of the client-side animation / js / etc. to be captured. If the web page is saved as a "white" image, try the above.


Vista / VS2005


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Comments and Discussions

GeneralMy vote of 5 Pin
S.H.Yadegari6-Sep-13 2:55
MemberS.H.Yadegari6-Sep-13 2:55 
QuestionVERY SKINNY Image created Pin
Ron Mittelman25-Oct-11 10:33
MemberRon Mittelman25-Oct-11 10:33 
AnswerRe: VERY SKINNY Image created Pin
Ron Mittelman25-Oct-11 10:55
MemberRon Mittelman25-Oct-11 10:55 
GeneralDoesn't seem to work on a page with JScript or ActiveX Pin
Steve Dunn22-Jun-10 8:37
MemberSteve Dunn22-Jun-10 8:37 
GeneralProblem with DrawToBitmap Pin
churchillr22-Apr-10 10:36
Memberchurchillr22-Apr-10 10:36 
QuestionMultiple Pages TIFF Pin
damifoo17-Mar-09 21:40
Memberdamifoo17-Mar-09 21:40 
QuestionHow can I read the screen text Pin
moreed10-Feb-09 21:30
Membermoreed10-Feb-09 21:30 
QuestionCan i plot this into web page? Pin
cavinsnipes25-Sep-08 3:01
Membercavinsnipes25-Sep-08 3:01 
Generaldoesn't convert big file Pin
shob_sp16-Jun-08 2:24
Membershob_sp16-Jun-08 2:24 
Generalhtml to image Pin
rejaneesh7-May-08 20:45
Memberrejaneesh7-May-08 20:45 
GeneralNot capturing whole page Pin
jfarias6-May-08 6:45
Memberjfarias6-May-08 6:45 
GeneralBeautiful! Pin
Dragon Soldier12-Nov-07 10:17
MemberDragon Soldier12-Nov-07 10:17 
QuestionUnhandled Exception ? Pin
Madra Beag2-Oct-07 14:30
MemberMadra Beag2-Oct-07 14:30 
AnswerRe: Unhandled Exception ? Pin
Nguyen Thanh Hai9-Nov-07 22:22
MemberNguyen Thanh Hai9-Nov-07 22:22 
GeneralRe: Unhandled Exception ? Pin
Puddin Tame14-Mar-17 17:18
MemberPuddin Tame14-Mar-17 17:18 
Questionhow can i save source code of web page in word document Pin
skhurams14-Sep-07 22:02
Memberskhurams14-Sep-07 22:02 
GeneralProblem with Popups & Fully loaded pages Pin
guilkerk17-Aug-07 9:34
Memberguilkerk17-Aug-07 9:34 
Questionwhat about web application? Pin
cbattioli16-Aug-07 10:44
Membercbattioli16-Aug-07 10:44 
GeneralLittle useful code Pin
Irwan Hassan15-Aug-07 18:05
MemberIrwan Hassan15-Aug-07 18:05 
GeneralRe: Little useful code Pin
Irwan Hassan23-Aug-07 3:09
MemberIrwan Hassan23-Aug-07 3:09 
QuestionHow to make it work if pages open within frames ? Pin
Vasanth Kumar14-Aug-07 17:25
MemberVasanth Kumar14-Aug-07 17:25 
AnswerRe: How to make it work if pages open within frames ? Pin
Irwan Hassan15-Aug-07 18:10
MemberIrwan Hassan15-Aug-07 18:10 
GeneralNice code. Pin
AndrewVos13-Aug-07 23:58
MemberAndrewVos13-Aug-07 23:58 
GeneralI am interested in get page contents (Java) and recognize contents Pin
sanong6-Aug-07 0:29
Membersanong6-Aug-07 0:29 
GeneralHave a look at Pin
Sacha Barber6-Aug-07 0:02
mvaSacha Barber6-Aug-07 0:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.