How to save the layout view as image or pdf to sd card in android? -


in application, have view customer details, want save view image or pdf sd card print view through third party application (otherwise print view directly through printer possible).

i have no idea of how save view image or pdf. can 1 know please me solve problem?

add permission in manifest file

<uses-permission android:name="android.permission.write_external_storage" /> 

use code below

linearlayout content = findviewbyid(r.id.rlid); content.setdrawingcacheenabled(true); bitmap bitmap = content.getdrawingcache(); file file,f;                     if (android.os.environment.getexternalstoragestate().equals(android.os.environment.media_mounted))      {            file =new file(android.os.environment.getexternalstoragedirectory(),"ttimages_cache");          if(!file.exists())         {           file.mkdirs();           }           f = new file(file.getabsolutepath()+file.seperator+ "filename"+".png");     }   fileoutputstream ostream = new fileoutputstream(f);                                      bitmap.compress(compressformat.png, 10, ostream);   ostream.close();   }   catch (exception e){  e.printstacktrace(); } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -