I\'m trying to display a PDF(which is created in the server side and pass to the client side as a web stream) through an AJAX call. My code is given below:
j
You can generate a temporary URL to access the PDF file stored on the server, instead of sending it back to the AJAX call. Just pass the generated URL back to the client. Then, when you receive the URL, you could for example do a window.location =
to redirect the browser to the download.
Make sure that the correct headers are set for the generated file (Content-Disposition: attachment
etc.), and all should be fine.
Edit: Although you could probably just use a regular (non-JavaScript) link to generate and download the file. But doing it via AJAX enables you to show some specific animation etc. to the user while the file is being generated.