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

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.


using (Doc doc = new Doc()) {   string theURL = "https://photojournal.jpl.nasa.gov/catalog/PIA24312";   // Set up the callback   StringBuilder theLog = new StringBuilder();   doc.HtmlOptions.HtmlCallback = (string stage, object page) => theLog.AppendLine(stage);   // Render html page   doc.AddImageUrl(theURL);   // Add log over the top of the content   doc.Rect.Inset(100, 100);   doc.Color.String = "255 0 0";   doc.FontSize = 96;   doc.AddText(theLog.ToString());   // Save the document   doc.Save(Server.MapPath("HtmlOptionsCallback.pdf")); }