I am using following code inside my android app to generate pdf :
HttpPost httppost = new HttpPost(“https://yogthos.p.mashape.com/”);
httppost.setHeader(“X-Mashape-Key”, “PWayfxCc28mshmb22rMFd8MDmNsWp1TXxTWjsnzgayj4Iy5sMx”);
httppost.setHeader(“Content-Type”, “application/x-www-form-urlencoded”);
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair(“json-input”,"[{}, [“paragraph”, “some text”]]"));
AbstractHttpEntity ent;
ent = new UrlEncodedFormEntity(nvps);
httppost.setEntity(ent);
HttpResponse response = httpclient.execute(httppost);
InputStream is = response.getEntity().getContent();
How can I download the pdf file? Kindly help.
Thanks.
Partecipa alla discussione - aggiungi un commento di seguito:
How do I open the return pdf with python-html (jinja2)?
I send the response in post function(data).
python:
self.response.write(response.body) //response instantpdf {‘content-type’: ‘application/pdf’, ‘date’: ‘Fri, 23 Jun 2017 10:01:56 GMT’, ‘connection’: ‘keep-
alive’, ‘server’: ‘Mashape/5.0.6’, ‘content-disposition’: ‘filename=document.pdf’, ‘content-length’: ‘860’, ‘via’: ‘1.1
vegur’}
and in js file, in post, i create
var file = new Blob([data], {type: ‘application/pdf’});
var fileURL = URL.createObjectURL(file);
and the restult is the blob link.
This does not work and the result is the blank pdf file
Could you help me please ?
Should I first bring the body response from file stream to file.pdf in python? Or there is another way
The API is free to use and the project is released as open source available here https://github.com/yogthos/instant-pdf so if you wanted to run your own copy you could do that as well.
Hi,
Thanks for your quick reply. Is this API free to use always? Can I rely to create an android app based on this? I am sorry to ask this, but I want to make sure.
Also is there any limit of requests at a time / per day / monthly basis?
Hi,
Thanks for your quick reply. Is this API free to use always? Can I rely to create an android app based on this? I am sorry to ask this, but I want to make sure.
Also is there any limit of requests at a time / per day / monthly basis?
You might want to look at downloading a binary from the response for example here http://stackoverflow.com/questions/8171835/java-download-binary-file-e-g-pdf-file-from-webserver