Handling Events
The Converter.Loaded event occurs after an HTML document has finished loading and is ready for conversion. You can handle this event to perform actions after the page and its resources have been loaded but before the PDF conversion process completes.
public event LoadedEventHandler Converter.Loaded;
Public Event Converter.Loaded As LoadedEventHandler
The event is handled using a LoadedEventHandler delegate, which receives a LoadedEventAgrs instance containing event-related data.
The following example demonstrates subscribing to the Converter.Loaded event and writing a message to the console when the HTML page has loaded successfully.
public static void Run(string outputPath)
{
Converter.Loaded += OnPageLoaded;
Converter.Convert(new Uri("https://www.google.com"), outputPath);
}
private static void OnPageLoaded(LoadedEventAgrs args)
{
Console.WriteLine("Page loaded.");
}
Public Shared Sub Run(outputPath As String)
AddHandler Converter.Loaded, AddressOf OnPageLoaded
Converter.Convert(New Uri("https://www.google.com"), outputPath)
End Sub
Private Shared Sub OnPageLoaded(
args As LoadedEventAgrs)
Console.WriteLine("Page loaded.")
End Sub