I need to generate a PDF file using some data I get from a POST request. As response to this request, I want to send the generated PDF file, for which the user should get a “save file as”-dialog.
This all should happen on the fly. I don’t want to save the PDF to the disk and serve it with an additional request. It should all happen with one single request.
But I don’t know how I could achieve such a thing. If I use a XMLHttRequest, I can’t make the “save-file-as”-dialog appear. On the other hand, if I use a form, I can’t send the POST data without some URL-encryption overhead.
Does anyone have an idea?
In the end, I solved it with 2 Requests. The first sends the needed data to the server and creates the PDF out of it, and then returns the ID of the temporary file. The second downloads the pdf and deletes the temporary file.