-
19 Feb 2013 12:49 AM #1
Unanswered: [BUG] PDF links cause application crash?
Unanswered: [BUG] PDF links cause application crash?
Hi all,
Has anyone tried building an app that includes links to PDF's? I've tried using versions 1.1.0.267 and 1.1.0.313, but both crash when clicking on the link to (seemingly) any PDF document.
A colleague of mine has also replicated this issue, so I suspect it's a generic problem rather than anything specific to my PC.
Does anyone have any ideas...?
Sencha Desktop - PDF crash.png
-
19 Feb 2013 5:11 AM #2
confirm
confirm
yes, it crashes... on win 7
-
20 Feb 2013 9:03 AM #3Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
- Answers
- 20
Thank you both for reporting this! Can you try opening the PDF links using the Ion.util.openUrl() API method, so PDFs are read using the default browser on the system? Inline PDF reader is not a feature of Desktop Packager, though we can consider it as a feature request(?). Nevertheless, we do not want it to crash!

Here's code you can put into your app to forward your .pdf hyperlinks to Ion.util.openUrl():
Code:document.body.addEventListener('click', function(e) { var t = e.target; if (t.tagName == 'A' && t.href.match(/\.pdf$/)) { e.preventDefault(); Ion.util.openUrl(t.href); } }, true);
-
22 Feb 2013 1:35 AM #4
Thanks for that. It works as you suggest in the context of the initial document body.
Unfortunately, for the project I'm working on, we really need it working on pages outside of the initial document body, i.e. those that are reached following links to other pages (as well as potentially iframed content).
Any other suggestions, or are we dependent on it being added as a feature?
-
22 Feb 2013 8:38 AM #5Sencha - Desktop Packager Dev Team
- Join Date
- Mar 2007
- Location
- Baltimore, MD.
- Posts
- 1,745
- Vote Rating
- 5
- Answers
- 20
Yes I do have one suggestion. You can disable cross-document security by specifying the "allowCrossSite" config option, for example:
With this turned on, cross-domain XHR requests and cross-frame communication is permitted. Now you can attach event listeners to the child iframe documents after they have loaded their document, and do the same sort of ushering of .pdf links to Ion.util.openUrl, e.g.:Code:{ "organizationName": "Sencha", "applicationName": "Area Chart", "versionString": "1.0", "outputPath": "AreaChart", "webAppPath": "src/", "settings": { "remoteDebuggingPort": 9123, "mainWindow": { "autoShow": true }, "security": { "allowCrossSite": true } } }
For pages that are loaded in and replace the main document, I have no suggested workaround for that at this time...you forfeit control at that point. I certainly suggest having a iframe shell so you can control all of the content.Code:var f = document.getElementById('frameId'); f.addEventListener('load', function() { f.contentWindow.document.body.addEventListener('click', function(e) { var t = e.target; if (t.tagName == 'A' && t.href.match(/\.pdf$/)) { e.preventDefault(); Ion.util.openUrl(t.href); } }, true); }, false);
Let me know if that workaround suffices. We do have PDF viewing as a ticketed feature request, so hopefully this is a temporary measure. Thanks.
You found a bug! We've classified it as
ION-1041
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote