angularjs - Download File PDF in Angular from Spring MVC -


i have situation. in angularjs:

    var graphhtml = $(".element10")[0];      $http({         method: 'post',          url: '/export/pdf',          data: "html=" + graphhtml.outerhtml,         headers: {'content-type': 'application/x-www-form-urlencoded'}     }).success(function(data, status, headers, config) {         var hiddenelement = document.createelement('a');         hiddenelement.href = 'data:application/pdf;' + encodeuri(data);         hiddenelement.target = '_blank';         hiddenelement.download = 'myfile.pdf';         hiddenelement.click();     }).error(function(data, status, headers, config) {     }); 

in spring:

    fileinputstream in = new fileinputstream(new file(mygeneratedfile));     outputstream out = response.getoutputstream();     final int buffersize = 8192;      byte[] buffer = new byte[buffersize];     int read;      while ((read = in.read(buffer, 0, buffersize)) != -1) {         out.write(buffer, 0, read);     } 

in javascript receive binary data of file pdf , save content in success section. when open file occurs problem format. issue function encodeuri? how can write correctly binary data? in advance


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -