Welcome Guest Search | Active Topics | Sign In | Register

EO.WebBrowser - Detect PDF Has Finished Loading? Options
KSystems
Posted: Thursday, March 17, 2016 7:34:50 PM
Rank: Advanced Member
Groups: Member

Joined: 1/15/2015
Posts: 43
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!
eo_support
Posted: Sunday, March 20, 2016 4:01:54 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
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.js

Hope this helps.

Thanks!
KSystems
Posted: Monday, March 21, 2016 12:51:09 AM
Rank: Advanced Member
Groups: Member

Joined: 1/15/2015
Posts: 43
This is pretty much what I was looking for, thanks!
eo_support
Posted: Monday, March 21, 2016 8:26:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
You are very welcome. Please feel free to let us know if there is anything else.

Thanks!
KSystems
Posted: Thursday, May 26, 2016 7:08:58 PM
Rank: Advanced Member
Groups: Member

Joined: 1/15/2015
Posts: 43
Unfortunately I found this works well within Chrome, but does not work within EO.WebBrowser. Am I missing something?

eo_support
Posted: Friday, May 27, 2016 12:02:11 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
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.
KSystems
Posted: Tuesday, May 31, 2016 1:35:24 PM
Rank: Advanced Member
Groups: Member

Joined: 1/15/2015
Posts: 43
I apologize, I was using an older version of EO.WebBrowser (2015). It is working fine with the latest version.
eo_support
Posted: Tuesday, May 31, 2016 1:44:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Glad to hear that. Please feel free to let us know if there is anything else.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.