Web 2.0 and Temporary PDFs

Hi,

When a web app generates a PDF (that’s different for every user), from what I understand, we have to save the PDF file to the server (temporary folder) first and then pass it on to the user with the WebFile class. However, does the temporary folder automatically dispose of the PDFs after a period of time, or is that something the app will need to handle? (Otherwise, I am thinking that one might end up with thousands of unwanted PDFs on the server after some period of time…)

Thank you. :slight_smile:

We can pass PDF data to WebFile class directly without temporary file.
We did that for years now.

1 Like

How would one go about that, as I am only seeing a “save” method for the PDFDocument class as an option? It does provide a string feature, but it says that is formatted in JSON instead. Hmm… :thinking:

Ah, the new class from Xojo. That may not do save to string, while MBS Xojo DynaPDF Plugin does.

1 Like

You can use the PDFDocument.ToString method to put the info directly into the Data property of the WebFile. Sorry, you will need to save it to disk first.
Just remember to keep the file around long enough for the user’s browser to access it!

1 Like

Docs say this returns a json string?

You are correct. Sorry about that.

Maybe its better to rename that function to .ToJSON to keep consistency. (Counter part .FromJSON)

Disclaimer: it’s just a suggestion take no offense in it.

Personally I have to agree, but because ToString already outputs JSON, the best we can do is to deprecate that method.

1 Like

I think that’s acceptable but it seems a bit inconsistent with api2.0 as it is now.