Convert files xls to pdf with Android and http apache mime -
that such night, write ask if , coregir following code, right through listview , presslong, took path of file, try , turn service: of: http://www.convertapi.com/excel-pdf-api
i have not use webview, or use hidden way thank
code is:
mprefs = getsharedpreferences("rutapath", context.mode_private); string rutasave = mprefs.getstring("externa", ""); string resultcode = "0"; httppost httppost = new httppost("http://do.convertapi.com/excel2pdf/json"); multipartentity entity = new multipartentity( httpmultipartmode.browser_compatible ); // file parameters file=new file(rutasave+"prueba.xls"); //toast.maketext(this,"cargando: " +rutasave+"prueba.xls",toast.length_short).show(); outputdir=rutasave; entity.addpart("file", new filebody(file, "binary/octet-stream"));//"file" httppost.setentity( entity ); httpclient httpclient = new defaulthttpclient(); // return new boolean(true);//eliminar despues try { httpresponse response = httpclient.execute(httppost); header rcheader = response.getfirstheader("result"); if(rcheader != null){ resultcode = rcheader.getvalue(); if("true".equals(resultcode)){ filesize = response.getfirstheader("filesize").getvalue(); filename = response.getfirstheader("outputfilename").getvalue(); //toast.maketext(this,"archivo: " +filename,toast.length_short).show(); httpentity hentity = response.getentity(); if(hentity != null){ inputstream istream = hentity.getcontent(); file file = new file(outputdir+filename+".pdf");//outputdir file.separator fileoutputstream ostream = new fileoutputstream(file); byte[] b = new byte[1024]; int num = 0; while( (num = istream.read(b, 0, b.length)) > 0) ostream.write(b, 0, num); istream.close(); ostream.flush(); ostream.close(); return new boolean(true); } } } } catch (clientprotocolexception e) {
Comments
Post a Comment