This is an archived forum post. The information may be outdated. Contact us if you have any questions.

PDF Binary data

indaroma wrote on 2013-10-02:
I am new to this and very confused as to what to do the with PDF binary data that I receive back to a successful ajax request.

I created a getPdf.php that I perform a Ajax post request on, passing in the html data. getPdf gets the proper username and token and calls the appropriate function in the pdfcrowd php file. The pdf is set to be sent back as attachment. My jQuery code gets a success callback with the data that is binary PDF. Now I am stuck and no idea how to open that as a save as or download as in my browser.

Here is my ajax request:

type: 'POST',
url: "../scripts/getPdf.php",
data: {
htmldat: htmldat
success: function(data){
error: function(data){
console.log('PDF fetch: failed' + data);

support wrote on 2013-10-02:

I would recommend that getPdf.php stores the PDF on your server and returns an URL instead of binary data. You can then call;

It should be possible to render the PDF binary data using the data URI scheme. However this is not portable across browsers and has several potential disadvantages."data:application/pdf," + escape(data.dataPdf));
indaroma wrote on 2013-10-03: