Logo
My Account |  Site Map | Contact Us  
 The same content in Microsoft HTML help file format is included in the download package.
HtmlToPdfSession.RunWebViewCallback Method (WebViewCallback, Object)

Run a WebViewCallback delegate in the context of this session.

Syntax
 public object RunWebViewCallback(
   WebViewCallback callback,
   object args
);

Parameters

callback
The WebViewCallback delegate to run.
args
Additional arguments to be passed to your delegate.

Return Value

Returns the value returned by the callback.

Remarks

Internally EO.Pdf use a WebView object to load the page and perform the conversion. You can use this method to interact with this underlying WebView object directly. For example, you can load a page and then execute certain JavaScript in WebView and then perform a conversion. The following code demonstrates how to use this feature:

//WebView and other related classes are defined in EO.WebBrowser 
//namespace. Also make sure EO.WebBrowser.dll is referenced by
//your project
using EO.WebBrowser;

using (HtmlToPdfSession session = HtmlToPdfSession.Create())
{
    //Run a callback in the session to load a special request
    session.RunWebViewCallback((WebView webView, object args) =>
        {
            //Create a EO.WebBrowser.Request object
            Request request = new Request(your_special_url);

            //Add some additional header entries
            request.Headers.Add(your_special_header_name, your_special_header_value);

            //Load the request
            webView.LoadRequestAndWait(request);

            return null;
        }, null);

    //Perform the conversion
    session.RenderAsPDF(result_pdf_file);
}

The following code demonstrates how to load a Url into the converter, then modify it with JavaScript before rendering the page:

//WebView and other related classes are defined in EO.WebBrowser 
//namespace. Also make sure EO.WebBrowser.dll is referenced by
//your project
using EO.WebBrowser;

using (HtmlToPdfSession session = HtmlToPdfSession.Create())
{
    //Run a callback in the session to load a special request
    session.RunWebViewCallback((WebView webView, object args) =>
    {
        //Load the Url
        webView.LoadUrl(url_to_be_converted);

        //Modify the page with JavaScript
        webView.EvalScript(javascript_to_modify_the_page);

        return null;
    }, null);

    //Perform the conversion
    session.RenderAsPDF(result_pdf_file);
}
See Also

Direct link to this topic