Hi,
This is a known limitation of our implementation. The full printing message flow (BeforePrint -> Get print settings -> AfterPrint) is only implemented on top level frames. Thus it is not possible to directly print iframes. One workaround to this limitation is to automatically copy the contents of the iframe into a top level frame using WebView.JSInitCode property:
Code: C#
webView.JSInitCode = @"
if (window.self !== window.top)
{
window.print = function()
{
var wnd = window.open("""", ""print"", """");
wnd.document.open();
wnd.document.write(document.documentElement.outerHTML);
wnd.document.close();
}
}
";
This code would override window.print for iframe only (by checking if (window.self !== window.top)) and perform the following task when window.print() is called on an iframe:
1. Use window.open to open a top level frame (For example, in TabbedBrowser sample application, this would open a new tab);
2. Copy the content of the iframe to the top level frame;
Once the copy finishes, whatever code that was in the original iframe that triggers window.print() will be automatically triggered again on the new top level frame. For example, in the code you posted it onload triggers window.print() on the iframe, thus it will be triggered again on the newly created top level frame. However since now it is a top level frame, window.print will sucessfully proceed and print the new frame.
Hope this helps. Please feel free to let us know if you still have any questions.
Thanks!