|
Rank: Advanced Member Groups: Member
Joined: 1/15/2015 Posts: 48
|
Hello,
I have a WinForm EO.WebControl that is loading a URL to a PDF. The WebBrowser seems to be loading the embedded PDF viewer, and not Adobe Reader (which is intended). I was wondering, is there any way to determine the PDF has finished loading in the PDF viewer? The WebView.LoadComplete Event fires before the PDF has fully loaded and displayed. I want to call print() when it is done loading. As of now, the print() is called too soon and printing blanks.
It would be great to handle this all client side, without resorting to embedding JavaScript into the PDF.
Thanks for any suggestions!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, You can try to use Chromium's PDF scripting API. The following code provides a sample HTML to show an alert box after the file has been loaded:
Code: HTML/ASPX
<html>
<body style="overflow:hidden;">
<embed width="100%" height="100%" id="pdf_viewer" src="your_pdf_file.pdf" />
<!-- Including PDFScriptingAPI. See below for details -->
<script type="text/javascript" src="pdf_scripting_api.js" />
<script>
<!-- Set a load callback -->
var plugin = document.getElementById("pdf_viewer");
var scriptingAPI = new PDFScriptingAPI(window, plugin);
scriptingAPI.setLoadCallback(function(success)
{
alert(success);
});
</script>
</body>
</html>
Here pdf_scripting_api.js is a file that is internally used by the built-in PDF viewer. You can find the full source code here: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/resources/pdf/pdf_scripting_api.jsHope this helps. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/15/2015 Posts: 48
|
This is pretty much what I was looking for, thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
You are very welcome. Please feel free to let us know if there is anything else.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 1/15/2015 Posts: 48
|
Unfortunately I found this works well within Chrome, but does not work within EO.WebBrowser. Am I missing something?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
KSystems wrote:Unfortunately I found this works well within Chrome, but does not work within EO.WebBrowser. Am I missing something?
Do you mean the above code we posted does not work? We tested it here and it does work fine.
|
|
Rank: Advanced Member Groups: Member
Joined: 1/15/2015 Posts: 48
|
I apologize, I was using an older version of EO.WebBrowser (2015). It is working fine with the latest version.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Glad to hear that. Please feel free to let us know if there is anything else.
|
|