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.
  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    2
    Vote Rating
    0
    mwagstaff is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha User
    Join Date
    Dec 2007
    Posts
    115
    Answers
    1
    Vote Rating
    12
    corvonero will become famous soon enough

      0  

    Default confirm

    confirm


    yes, it crashes... on win 7

  3. #3
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Answers
    20
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    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);

  4. #4
    Sencha User
    Join Date
    Feb 2013
    Posts
    2
    Vote Rating
    0
    mwagstaff is on a distinguished road

      0  

    Default


    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?

  5. #5
    Sencha - Desktop Packager Dev Team jarrednicholls's Avatar
    Join Date
    Mar 2007
    Location
    Frederick, MD
    Posts
    1,747
    Answers
    20
    Vote Rating
    7
    jarrednicholls will become famous soon enough jarrednicholls will become famous soon enough

      0  

    Default


    Yes I do have one suggestion. You can disable cross-document security by specifying the "allowCrossSite" config option, for example:

    Code:
    {
        "organizationName": "Sencha",
        "applicationName": "Area Chart",
        "versionString": "1.0",
        "outputPath": "AreaChart",
        "webAppPath": "src/",
        "settings": {
            "remoteDebuggingPort": 9123,
            "mainWindow": {
                "autoShow": true
            },
            "security": {
                "allowCrossSite": true
            }
        }
    }
    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:
    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);
    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.

    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.

Thread Participants: 2

Tags for this Thread