Table of Contents
  • Getting Started
  • EO.Pdf
  • EO.Web
  • EO.WebBrowser
  • EO.Wpf
  • Common Topics
  • Reference
    • .NET API Reference
      • EO.Base
      • EO.Base.UI
      • EO.Extensions
      • EO.Pdf
      • EO.Pdf.Acm
      • EO.Pdf.Contents
      • EO.Pdf.Drawing
      • EO.Pdf.Mvc
      • EO.Web
      • EO.WebBrowser
      • EO.WebBrowser.DOM
      • EO.WebEngine
      • EO.WinForm
      • EO.Wpf
      • EO.Wpf.Gauge
      • EO.Wpf.Gauge.Shapes
      • EO.Wpf.Primitives
      • EO.Wpf.Themes.Aero
      • EO.Wpf.Themes.Classic
      • EO.Wpf.Themes.Luna
      • EO.Wpf.Themes.Metro
      • EO.Wpf.Themes.Royale
    • JavaScript API Reference
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