Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Can't get PDF to show in IFrame

  1. #1
    Join Date
    Mar 2009
    Location
    Beech Hill - a village near Reading in the UK
    Posts
    2,812

    Default Can't get PDF to show in IFrame

    I am trying to do a pretty simple thing and ATM it just isn't working.

    Code:
    Use cWebModalDialog.pkg
    Use cWebPanel.pkg
    Use cWebButton
    Use cWebIFrame.pkg
    
    Object oViewer is a cWebModalDialog
        Set psCaption to "Viewer"
        Set piMinWidth to 1000
        Set piMinHeight to 800
        
        Object oMainPanel is a cWebPanel
            Set piColumnCount to 12
    
            Object oIFrame is a cWebIFrame
                Set piHeight to 700
                Set piColumnSpan to 0
                Set pbFillHeight to True
            End_Object
            
        End_Object 
        
        Object oBottomPanel is a cWebPanel
            Set peRegion to prBottom
            Set piColumnCount to 12
            
            Object oCancelButton is a cWebButton
                Set psCaption to "Close"
                Set piColumnSpan to 1
                Set piColumnIndex to 11
    
                Procedure OnClick
                    Send Cancel
                End_Procedure
                
            End_Object 
            
        End_Object 
    
        Procedure PopupTheDialog Handle hReturnObj String sPath
            String sUrl
            
            Send Popup hReturnObj
            Get DownloadURL of ghoWebResourceManager sPath to sURL
            WebSet psUrl of oIFrame to sURL
        End_Procedure
        
    End_Object
    PopupTheDialog is called with the full file-path of a PDF file, which exists (C:\Statements\2015-02-25_2600370051.PDF, if it matters); C:\Statements has been registered as download folder; Get DownloadURL gets a pile of gobbledygook (DfResource/0EM_LYbShFZFjrXdIcn_IMjOjnTCe3WFTXXb5PN_RavG0d1JEj MGewmh_2KsqcbxgGKGnf-BFU9HjG-4P9wmTJTaSZ1-G_Hli126vY1gjva3mBE3c26zcQVn111P31mK0/2015-02-25_2600370051.PDF) into sURL, but when the dialog comes up, the IFrame is blank.

    Can anybody see what I am doing wrong?

    I am looking at that URL in the forum preview and seeing an apparent space character between "...JEj" and "MGew..." which isn't visible in what I pasted into the forum editor... wonder if that is a clue? Nah! I just moved it to a UChar[] and it isn't there - just "...1JEjMGew..." obviously a forum artifact.

    Mike
    Last edited by Mike Peat; 2-Dec-2019 at 12:25 PM. Reason: an

  2. #2
    Join Date
    Aug 2019
    Location
    Cantabria, Spain
    Posts
    252

    Default Re: Can't get PDF to show in IFrame

    Mike,
    I'm working with PDFs and IFrames right now. Check your output panel, it might tell you the Download Folder is not registered. Sometimes I forget to register the required folder. If that is the case, try registering that folder on your cWebResourceManager.

    Click image for larger version. 

Name:	screenshot.PNG 
Views:	76 
Size:	9.9 KB 
ID:	13279

  3. #3
    Join Date
    Mar 2009
    Location
    Beech Hill - a village near Reading in the UK
    Posts
    2,812

    Default Re: Can't get PDF to show in IFrame

    Thanks Alberto

    However in WebApp.src on startup:
    Code:
    Send RegisterDownloadFolder of ghoWebResourceManager sPath  // sPath is "C:\Statements" at this point
    And no mention of it in my output panel.

    Mike

  4. #4
    Join Date
    Aug 2019
    Location
    Cantabria, Spain
    Posts
    252

    Default Re: Can't get PDF to show in IFrame

    Mike,
    I tested it and it doesn't work for me either. Something might be wrong when we combine the DownloadURL function with a cWebModalDialog control or something like that. However, I got it working (I know it isn't the optimal solution):
    Modify your code and replace the DownloadURL line with the following:

    Code:
    // Get DownloadURL of ghoWebResourceManager sPath to sURL
    Get CustomDownloadURL of ghoWebResourceManager sPath False "file.pdf" True 0 to sURL
    Being "file.pdf" whatever you want (e.g., extract the filename from sPath) and 0 the piDownloadTimeout value of cWebResourceManager.

    This way you can get it working until someone with more knowledge tells us how to fix DownloadURL
    Last edited by Alberto Gutiérrez Arroyo; 3-Dec-2019 at 03:47 AM. Reason: Some typos

  5. #5
    Join Date
    Mar 2009
    Location
    Beech Hill - a village near Reading in the UK
    Posts
    2,812

    Default Re: Can't get PDF to show in IFrame

    Alberto

    Thanks - I'll try that right now!

    Mike

  6. #6
    Join Date
    Mar 2009
    Location
    Beech Hill - a village near Reading in the UK
    Posts
    2,812

    Default Re: Can't get PDF to show in IFrame

    Alberto

    Nope, that didn't work for me either.

    However... changing the bAttachment parameter to True offered me the "Open or Save" dialog and if I chose to open it (picking the same browser I am using for the WebApp) it did open it in a new tab (or if choosing a different browser, opened it in that), although using that URL as a parameter to either NavigateToPage or NavigateToPage does not work, even if the iTimeout parameter is increased (to, say, 1) and the bBindSession parameter is changed to False.

    Odd that my code didn't work for you either, but that the CustomDownloadURL did for you, but not for me. ATM, my theory is that the gods just hate me.

    Mike
    Last edited by Mike Peat; 3-Dec-2019 at 05:05 AM. Reason: sp

  7. #7
    Join Date
    Mar 2009
    Location
    Beech Hill - a village near Reading in the UK
    Posts
    2,812

    Default Re: Can't get PDF to show in IFrame

    OK, a bit more info...

    Using:
    Code:
    Get CustomDownloadURL of ghoWebResourceManager sPath False "" True 0 to sURL // (sometimes I give a name rather than "" - doesn't seem to make a difference)
    I am testing locally with Firefox and the foregoing holds true for that.

    If I test remotely with Chrome (on MacOS) it offers me a Save dialog. If I test locally with Chrome (on Windows, obviously) it gives me a downloaded file thingy at the bottom of the browser window and if I click on that it opens the PDF in a new tab... but on the local file (as in file:///C:/Users/Mike/Downloads/2015-02-25_2600370051%20(3).PDF - the (3) obviously because I've repeated the process several times). This is because on the local Chrome it is downloading to my downloads folder automatically, while on remote it is set to allow me to choose. IE does the download thing too, but much, much clunkier and never actually displays the file, 'coz it is cr4p!

    Help! This should be easy!

    Mike

  8. #8
    Join Date
    Aug 2019
    Location
    Cantabria, Spain
    Posts
    252

    Smile Re: Can't get PDF to show in IFrame

    Mike, found it.
    I had experienced this problem in the past, but I had forgotten what caused it. It is very simple and funny: An uppercase file extension!
    If you generate the URL of the file with an uppercase extension, the frame won't show it and it will send it to the download queue of the browser. If you convert it to lowercase before creating the URL, everything should work. Here is the test view I created, I hope you can fix it with this.

    IFrameTest.wo
    Last edited by Alberto Gutiérrez Arroyo; 3-Dec-2019 at 06:44 AM. Reason: Formatting

  9. #9
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    5,446

    Default Re: Can't get PDF to show in IFrame

    Samuel Pizarro

  10. #10
    Join Date
    Mar 2009
    Location
    Beech Hill - a village near Reading in the UK
    Posts
    2,812

    Default Re: Can't get PDF to show in IFrame

    Bazinga! Well done and thank you Alberto!

    I kinda think that's a bug, but now I know how to work around it.

    Mike

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •