Second pdf fails after downloading first one

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

Javier MenendezXojo, Inc.

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

Hi @Dean_Davidge , are you developing in Web 1.0 or Web 2.0 ?

“I based the code on…”

Show us the code.

Hi @Dean_Davidge

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
1 Like

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 :slight_smile:

My previous post fixes the issue. Tested on macOS, Windows and Linux. :wink:

1 Like

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.

1 Like

Gotcha glad it’s resolved!

1 Like

Sorry to ask again - I haven’t got an answer - is this for Web 1.0 or Web 2.0 ?

Thanks

No problem, is Web 2.0, you can visit Dean’s page here: https://catalog.ezmeter.net/

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.