javascript - Phantomjs : How to download and save a PDF file which is received as attachment in response header? Please give solution using Phantomjs only -


i trying download pdf file using phantomjs. there no direct url downloading pdf calls internal javascript function when click submit button. here code using download pdf file :-

 page.open(url, function(status){      page.evaluate(function(){          document.getelementbyid('id').click();      });  });  page.onresourcereceived = function(request){         console.log('received ' + json.stringify(request, undefined, 4));  }; 

the 'id' element id submit button. problem here though getting response (inside onresourcereceived callback) json format not able save attachment pdf file.

when run above code, following output json string.

output :

 received {     "contenttype": "application/pdf",     "headers": [         // other headers.         {             "name": "content-type",             "value": "application/pdf"         },         {             "name": "content-disposition",             "value": "attachment; filename=filename.pdf"         },     ],     "id": 50,     "redirecturl": null,     "stage": "end",     "status": 200,     "statustext": "ok",     "url": "http://www.someurl.com" } 


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -