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.


Properties

Options that affect CaptureWebpage and CaptureHTML methods.

Options that affect SaveImage method.

Options that affect GetImage method.

Methods description


Method Description
CaptureWebpage Summary:
Capture webpage from url or local path.
Parameters:
strURL: Website page url or HTML/MHTML file path.
Return Value:
WebsitesScreenshot.Result, result of the capturing process (Captured, Failed, Timeout).
Example:
CaptureWebpage("www.google.com");
CaptureWebpage("c:\mypage.html");
CaptureWebpageAsync Summary:
Asynchronize method to capture webpage from url or local path.
Parameters:
strURL: Website page url or HTML/MHTML file path.
Return Value:
Return value can be handled in CaptureResult event.
Example:
CaptureWebpageAsync("www.google.com");
CaptureWebpageAsync("c:\mypage.html");
CaptureHTML Summary:
Capture HTML code and convert it to image.
Parameters:
strHTMLCode: HTML code.
Return Value:
WebsitesScreenshot.Result, result of the capturing process (Captured, Failed, Timeout).
Example:
CaptureHTML("<html><body><h1> Hello world </h1></body></html>");
CaptureHTMLAsync Summary:
Asynchronize method to capture HTML code and convert it to image.
Parameters:
strHTMLCode: HTML code.
Return Value:
Return value can be handled in CaptureResult event.
Example:
CaptureHTMLAsync("<html><body><h1> Hello world </h1></body></html>");
SaveImage Summary:
Save the resulting image.
Parameters:
strImageName: Output image name with full path.
Example:
SaveImage("c:\\mypage.jpg");
GetImage Summary:
Get the resulting image in memory.
Return Value:
System.Drawing.Bitmap
Example:
System.Drawing.Bitmap _Image;
_Image=_Obj.GetImage();
GetHtmlDocument Summary:
Get HTML document object of the captured web page.
Return Value:
mshtml.HTMLDocumentClass
Example:
IHTMLDocument2 _HTMLDocument;
_HTMLDocument = _Obj.GetHtmlDocument();
GetDocumentSource Summary:
Get HTML Source of the captured web page.
Return Value:
System.String
Example:
System.String _HTML;
_HTML=_Obj.GetDocumentSource();
GetDocumentTitle Summary:
Get the title of the captured web page.
Return Value:
System.String
Example:
System.String _Title;
_Title=_Obj.GetDocumentTitle();
GetDocumentText Summary:
Get the text content of the captured web page.
Return Value:
System.String
Example:
System.String _Text;
_Text=_Obj.GetDocumentText();
GetDocumentLinks Summary:
Get the URLs of links on the captured web page.
Return Value:
string[]
Example:
string[] _Links=null;
_Links=_Obj.GetDocumentLinks();
GetDocumentImages Summary:
Get the URLs of images on the captured web page.
Return Value:
string[]
Example:
string[] _Images=null;
_Images=_Obj.GetDocumentImages();
GetDocumentFrames Summary:
Get the URLs of frames on the captured web page.
Return Value:
string[]
Example:
string[] _Frames=null;
_Frames=_Obj.GetDocumentFrames();

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");
	}            
}