Methods
-
Methods to capture website page, render html.
- CaptureWebpage: Caputre screenshot of website page.
- CaptureHTML: Render HTML code as image, Convert HTML to Image.
-
Methods to access resulting image.
- SaveImage: Save captured screenshot, thumbnail.
- GetImage: Get captured screenshot in memory.
-
Methods to access HTML document and others.
- GetHtmlDocument: Get the HTML document object of the captured website page.
- GetDocumentSource: Get the HTML source of the captured website page.
- GetDocumentTitle: Get the title of the captured website page.
- GetDocumentText: Get the text content of the captured website page.
- GetDocumentLinks: Get the URLs of links on the captured website page.
- GetDocumentImages: Get the URLs of images on the captured website page.
- GetDocumentFrames: Get the URLs of frames on the captured website page.
Properties
- BrowserWidth: Width of the browser.
- BrowserHeight: Height of the browser.
- TimeOutSeconds: Timeout for the process.
- DelaySeconds: Seconds for the delayed snapshot.
- NoActiveX: To disable activex on the page.
- NoJava: To disable java on the page.
- NoScripts: To disable scripts on the page.
- Force: Forcefully take the screenshot if timeout.
- ImageFormat: Format of the output image.
- ImageWidth: Width of the output image.
- ImageHeight: Height of the output image.
- PreserveAspectRatio: Preserve aspect ratio when applying width or height to the output image.
- JpegQuality: JPEG quality for the output image.
- ImageWidth: Width of the output image.
- ImageHeight: Height of the output image.
- PreserveAspectRatio: Preserve aspect ratio when applying width or height to the output image.
Methods description
Even for asynchronize result
| Event | Description |
|---|---|
| CaptureResult | Handle this event to get the result of CaptureWebpageAsync and CaptureHTMLAsync methods, get the result in Enum Result (Values: Captured, Failed, Timeout) |
Properties for CaptureWebpage and CaptureHTML methods
| Property | Description | Default Value | BrowserWidth | Browser width | Automatically determined |
|---|---|---|
| BrowserHeight | Browser Height | Automatically determined |
| TimeOutSeconds | Timeout in seconds, timeout value for the process | 120 |
| DelaySeconds | Delay in seconds. After page loads, take screenshot after specified seconds. Useful for the page containing flash or other ActiveX | 0 |
| NoActiveX | Disable ActiveX on the page | False |
| NoJava | Disable Java on the page | False |
| NoScripts | Disable Scripts on the page | False |
| Force | Force to take screenshot if timeout | False |
Properties for SaveImage method
| Property | Description | Default Value |
|---|---|---|
| ImageFormat | Format of output image Values: JPG, GIF, PNG, BMP, TIF |
ImageFormats.JPG |
| ImageWidth | Width of the output image | Automatically determined |
| ImageHeight | Height of the output image | Automatically determined |
| PreserveAspectRatio | Preserve aspect ratio when applying width or height to the output image | False |
| JpegQuality | Jpeg quality for output image Values: 0 to 100 |
100 |
Properties for GetImage method
| Property | Description | Default Value |
|---|---|---|
| ImageWidth | Width of the output image | Automatically determined |
| ImageHeight | Height of the output image | Automatically determined |
| PreserveAspectRatio | Preserve aspect ratio when applying width or height to the output image | False |
Sample Code
The following code sample shows how to create full size PNG screenshot from a website page url.
VB .Net code.
Dim _Obj As New WebsitesScreenshot.WebsitesScreenshot
Dim _Result As WebsitesScreenshot.WebsitesScreenshot.Result
With _Obj
_Result = .CaptureWebpage("http://www.google.com")
If _Result = WebsitesScreenshot.WebsitesScreenshot. _
Result.Captured Then
.ImageFormat = WebsitesScreenshot. _
WebsitesScreenshot.ImageFormats.PNG
.SaveImage("c:\google.png")
End If
End With
_Obj.Dispose()
C# .Net Code.
WebsitesScreenshot.WebsitesScreenshot _Obj;
_Obj = new WebsitesScreenshot.WebsitesScreenshot ();
WebsitesScreenshot.WebsitesScreenshot.Result _Result;
_Result = _Obj.CaptureWebpage("http://www.google.com");
if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured)
{
_Obj.ImageFormat = WebsitesScreenshot.
WebsitesScreenshot.ImageFormats.PNG;
_Obj.SaveImage ("c:\\google.png");
}
_Obj.Dispose();
The following code sample shows how to convert local html/mhtml file to image.
VB .Net code.
Dim _Obj As New WebsitesScreenshot.WebsitesScreenshot
Dim _Result As WebsitesScreenshot.WebsitesScreenshot.Result
With _Obj
_Result = .CaptureWebpage("c:\myhtml.html")
If _Result = WebsitesScreenshot.WebsitesScreenshot. _
Result.Captured Then
.ImageFormat = WebsitesScreenshot. _
WebsitesScreenshot.ImageFormats.BMP
.SaveImage("c:\test.bmp")
End If
End With
_Obj.Dispose()
C# .Net code.
WebsitesScreenshot.WebsitesScreenshot _Obj;
_Obj=new WebsitesScreenshot.WebsitesScreenshot();
WebsitesScreenshot.WebsitesScreenshot.Result _Result;
_Result = _Obj.CaptureWebpage("c:\\myhtml.html");
if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured)
{
_Obj.ImageFormat = WebsitesScreenshot.
WebsitesScreenshot.ImageFormats.BMP;
_Obj.SaveImage("c:\\test.bmp");
}
_Obj.Dispose();
The following code sample shows how to render html code to gif.
VB .Net code.
Dim _Obj As New WebsitesScreenshot.WebsitesScreenshot
Dim _Result As WebsitesScreenshot.WebsitesScreenshot.Result
With _Obj
_Result = .CaptureHTML( _
"<html><body><h1> Hello world </h1></body></html>")
If _Result = WebsitesScreenshot.WebsitesScreenshot. _
Result.Captured Then
.ImageFormat = WebsitesScreenshot. _
WebsitesScreenshot.ImageFormats.GIF
.SaveImage("c:\test.gif")
End If
End With
_Obj.Dispose()
C# .Net code.
WebsitesScreenshot.WebsitesScreenshot _Obj;
_Obj=new WebsitesScreenshot.WebsitesScreenshot();
WebsitesScreenshot.WebsitesScreenshot.Result _Result;
_Result = _Obj.CaptureHTML(
"<html><body><h1> Hello world </h1></body></html>");
if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured)
{
_Obj.ImageFormat = WebsitesScreenshot.
WebsitesScreenshot.ImageFormats.GIF;
_Obj.SaveImage("c:\\test.gif");
}
_Obj.Dispose();
The following code sample shows how to get the resulting image in the memory.
VB .Net code.
Dim _Obj As New WebsitesScreenshot.WebsitesScreenshot
Dim _Result As WebsitesScreenshot.WebsitesScreenshot.Result
Dim _MyBitmap As System.Drawing.Bitmap
With _Obj
_Result = .CaptureWebpage("www.google.com")
If _Result = WebsitesScreenshot.WebsitesScreenshot. _
Result.Captured Then
_MyBitmap = .GetImage
End If
End With
_Obj.Dispose()
C# .Net code.
WebsitesScreenshot.WebsitesScreenshot _Obj;
_Obj=new WebsitesScreenshot.WebsitesScreenshot();
WebsitesScreenshot.WebsitesScreenshot.Result _Result;
System.Drawing.Bitmap _MyBitmap;
_Result = _Obj.CaptureWebpage("www.google.com");
if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured)
{
_MyBitmap = _Obj.GetImage();
}
_Obj.Dispose();
The following code sample shows how to capture website with flash content, which takes time to load.
VB .Net code.
Dim _Obj As New WebsitesScreenshot.WebsitesScreenshot
Dim _Result As WebsitesScreenshot.WebsitesScreenshot.Result
With _Obj
.DelaySeconds = 30
_Result = .CaptureWebpage("www.SiteWithFlash.com")
If _Result = WebsitesScreenshot.WebsitesScreenshot. _
Result.Captured Then
.SaveImage("c:\test.jpg")
End If
End With
_Obj.Dispose()
C# .Net code.
WebsitesScreenshot.WebsitesScreenshot _Obj;
_Obj=new WebsitesScreenshot.WebsitesScreenshot();
WebsitesScreenshot.WebsitesScreenshot.Result _Result;
_Obj.DelaySeconds = 30;
_Result = _Obj.CaptureWebpage("www.SiteWithFlash.com");
if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured)
{
_Obj.SaveImage("c:\\test.jpg");
}
_Obj.Dispose();
The following code sample shows how to generate website page thumbnail image (asynchronize).
VB .Net code.
Dim WithEvents __AsyncWebsitesScreenshot As New _
WebsitesScreenshot.WebsitesScreenshot
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
With __AsyncWebsitesScreenshot
.CaptureWebpageAsync("www.google.com")
End With
End Sub
Private Sub __AsyncWebsitesScreenshot_CaptureWebpageResult _
(ByVal pResult As WebsitesScreenshot.WebsitesScreenshot.Result) _
Handles __AsyncWebsitesScreenshot.CaptureResult
If pResult = WebsitesScreenshot.WebsitesScreenshot. _
Result.Captured Then
With __AsyncWebsitesScreenshot
.ImageWidth = 100
.ImageHeight = 100
.SaveImage("c:\google.jpg")
End With
End If
End Sub
C# .Net code.
private WebsitesScreenshot.WebsitesScreenshot __AsyncWebsitesScreenshot;
private void button4_Click(object sender, EventArgs e)
{
__AsyncWebsitesScreenshot = new WebsitesScreenshot.
WebsitesScreenshot();
__AsyncWebsitesScreenshot.CaptureResult += new
WebsitesScreenshot.WebsitesScreenshot
.CaptureResultEventHandler(
__AsyncWebsitesScreenshot_CaptureWebpageResult);
__AsyncWebsitesScreenshot.CaptureWebpageAsync("www.google.com");
}
private void __AsyncWebsitesScreenshot_CaptureWebpageResult
(WebsitesScreenshot.WebsitesScreenshot.Result pResult)
{
if (pResult == WebsitesScreenshot.
WebsitesScreenshot.Result.Captured)
{
__AsyncWebsitesScreenshot.ImageWidth = 100;
__AsyncWebsitesScreenshot.ImageHeight= 200;
__AsyncWebsitesScreenshot.SaveImage ("c:\\google.jpg");
}
}
