Type Default Value Read Only Description

[Visual Basic]
null No The multicast delegate to be called while HTML rendering is taking place.




This delegate is called during HTML rendering.

During the time that HTML rendering is taking place delegates are called periodically. This gives a mechanism for tracking progress and for intercepting and modifying or querying pages on the fly.

If the page is obtained from the cache then the delegate will not be called.

Note that the amount of work done during a callback should be kept to a minimum.

The definition of the HtmlCallback multicast delegate is as follows.

delegate void HtmlCallback(string stage, object page);

[Visual Basic]
Delegate Sub HtmlCallback(stage As String, page As Object);

Current values for the stage variable are 'get width', 'get height' and 'render'. The first occurs prior to finding the natural width of the HTML (the width it can occupy without scrolling). The second occurs prior to finding the natural height. The third occurs prior to translation into PDF format.

The page is provided via a mshtml.HTMLDocumentClass object - see Microsoft documentation for details. However note that while the interface is standard the behavior may not be identical. For example element positions may not be available.




The following example shows the effect that this parameter has on HTML rendering.

Doc theDoc = new Doc();
string theURL = "http://www.nasa.gov/multimedia/imagegallery/image_feature_302.html";
// Setup the callback
theDoc.HtmlOptions.HtmlCallback = MyHtmlCallback;
// Render html page
// Add log over the top of the content
theDoc.Rect.Inset(100, 100);
theDoc.Color.String = "255 0 0";
theDoc.FontSize = 96;
// Save the document

private static string theLog = "";
public static void MyHtmlCallback(string stage, object page)
  theLog += stage + "\n";

[Visual Basic]
Dim theDoc As Doc = New Doc()
Dim theURL As String = "http://www.nasa.gov/multimedia/imagegallery/image_feature_302.html"
' Setup the callback
theDoc.HtmlOptions.HtmlCallback = AddressOf MyHtmlCallback
' Render html page
' Add log over the top of the content
theDoc.Rect.Inset(100, 100)
theDoc.Color.String = "255 0 0"
theDoc.FontSize = 96
' Save the document

[Visual Basic]
Private Shared theLog As String = ""
Public Shared Sub MyHtmlCallback(stage As String, page As Object)
  theLog = theLog + stage + "\n"
End Sub