My web app generates pdfs that are displayed in a WebHTMLViewer. If a user downloads a pdf, subsequent attempts to display a second one fail. The code runs, but the pdf is not displayed. Starting a new session allows new pdfs to be displayed until one is downloaded. I based the code on the EE-Web example which has the same problem. I have not been able to find a work around.
Do you set the downloaded file instance to nil before creating a new PDFDocument instance?
For example in the EE Web, that is done setting session.PDFFile = Nil
Do you set the downloaded file instance to nil before creating a new PDFDocument instance?
For example in the EE Web, that is done setting
session.PDFFile = Nil
I already did that and it dis not help
“I based the code on…”
Show us the code.
Try this instead in order to download the file while keeping the WebHTMLViewer working:
Session.PDFFile = Nil
Session.PDFFile = New WebFile
Session.PDFFile.MIMEType = "application/pdf"
Session.PDFFile = webfile.Open(Session.PDFFolderItem)
Session.PDFFile.ForceDownload = False
Call Session.PDFFile.download
EE-Web
Examples - PDF - EE-Web - EE-PDF-Web.xojo_binary_project
I’m not going to guess what the differences are. Always happy to help but without seeing the code we’re all just guessing.
We’re developers we can do better than that
My previous post fixes the issue. Tested on macOS, Windows and Linux.
There are no differences, the Example works exactly as Dean describes, you can click ‘New PDF’ several times and it works (for the example) but as soon as you click ‘Download’ and then try ‘New PDF’ again, it doesn’t display anything.
We need to update the example code with what Javier posted above.
Gotcha glad it’s resolved!
Sorry to ask again - I haven’t got an answer - is this for Web 1.0 or Web 2.0 ?
Thanks
This morning there was another answer to my query that was not part of this chain. It suggested using a second, but not visible, WebHTMLViewer to download the pdf. I did and it works. Thanks to everyone for your input on this.