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
[/code]
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_RavG0d1JEjMGewmh_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
1 Attachment(s)
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.
[ATTACH=CONFIG]13279[/ATTACH]
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
[/code]
And no mention of it in my output panel. :(
Mike
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[/CODE]
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 :)
Re: Can't get PDF to show in IFrame
Alberto
Thanks - I'll try that right now! :)
Mike
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
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)
[/code]
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! :D
Help! This should be easy!
Mike
1 Attachment(s)
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.
[ATTACH]13280[/ATTACH]
Re: Can't get PDF to show in IFrame
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