|Language:||English, Spanish, Dutch|
|Genre:||Business & Career|
|ePub File Size:||18.61 MB|
|PDF File Size:||14.35 MB|
|Distribution:||Free* [*Regsitration Required]|
George Maharis George Maharis 3 Once again: You can also use the below options to login. Linked 2. Maximum characters. Replies 4. Another solution involving two requests:
Response title. Publish Back to edit Cancel. Sign In. New to this Portal? Click here to Sign up.
You can also use the below options to login. Search jQuery Search. Move this topic Cancel.
Using jQuery. How topdf string from ajax as pdf in browser Replies 4.
Have a look at this - http: Leave a comment on jay. Can I return it as a base64 text string?
They might not be useful for me, but nice to see Just interesting. If you want to use the browser's default viewer and only one request, why you can not encode on the server side pdf file e.
You don't necessarily need Ajax for this. This way the parent page will just stay open, if that was your major concern why would you unnecessarily have chosen Ajax for this otherwise?
Besides, there is no way to handle this nicely acynchronously. PDF is not character data. It's binary data. You want to use completely new request for this. To assist you more with the server side code, you'll need to tell more about the language used and post an excerpt of the code attempts. I don't really think that any of the past answers spotted out the problem of the original poster. In its "heart" it creates a "temporary" HTML form containing the given data as input fields.
This form is appended to the document and posted to the desired URL. Right after that the form is removed again:. Update Mayur's answer looks pretty promising and very simple in comparison to the jQuery plug-in I referred to.
This is how i solve this issue. The answer of Jonathan Amend on this post helped me a lot. The example below is simplified. A simple event on button click. It creates an AjaxDownloadFile object. The AjaxDownloadFile class source is below.
What worked for me is the following code, as the server function is retrieving File memoryStream. This worked for me. Found this plugin here. This snippet is for angular js users which will face the same problem, Note that the response file is downloaded using a programmed click event.
Concerning the answer given by Mayur Padshala this is the correct logic to download a pdf file via ajax but as others report in the comments this solution is indeed downloads a blank pdf.
The reason for this is explained in the accepted answer of this question: To fix the blank PDF issue in post request to get stream data like PDF, we need to add response type as 'arraybuffer' or 'blob' in request.
If you have to work with file-stream so no physically saved PDF like we do and you want to download the PDF without page-reload, the following function works for us:. Hope this will save you a few hours and spare you from a headache. Solution was this:. Include download.
The results are in! See what nearly 90, developers picked as their most loved, dreaded, and desired coding languages and more in the Developer Survey. I have an action class that generates a PDF. The contentType is set appropriately.
Your browser sent a request that this server could not understand. Mike B. Nayn Nayn 1, 7 30