Posts

Showing posts from June, 2017

how to save image to pdf in android

//make function inside the activity public void convertPDF( byte [] path) { //String FILE = "mnt/sdcard/FirstPdf.pdf"; Document document= new Document(); File direct = new File(Environment. getExternalStorageDirectory () + "/collage app pdf" ); if (!direct.exists()) { File wallpaperDirectory = new File( "/sdcard/collage app pdf/" ); wallpaperDirectory.mkdirs(); } File f = null ; f = new File(direct, UUID. randomUUID ().toString() + ".pdf" ); if (f.exists()) { f.delete(); } try { PdfWriter. getInstance (document, new FileOutputStream(f)); document.open(); try { Image image=Image. getInstance (path); document.add( new Paragraph( "Collage Pic" )); document.add(image); document.close(); Toast. makeText (getContext(), "pdf save successfully" , Toast. LENGTH_SHORT ).show();...

how to save image to sdcard folder from array in android

public void SaveImage(){ BitmapDrawable btmpDr = (BitmapDrawable) mCollageImageView .getDrawable(); Bitmap bmp = btmpDr.getBitmap(); File direct = new File(Environment. getExternalStorageDirectory () + "/collage app image" ); if (!direct.exists()) { File wallpaperDirectory = new File( "/sdcard/collage app image/" ); wallpaperDirectory.mkdirs(); } File f = null ; f = new File(direct, UUID. randomUUID ().toString() + ".png" ); if (f.exists()) { f.delete(); } try { FileOutputStream out = new FileOutputStream(f); bmp.compress(Bitmap.CompressFormat. JPEG , 100 , out); out.flush(); out.close(); Toast.makeText(getContext(), "Image is saved successfully." , Toast. LENGTH_SHORT ).show(); } catch (Exception e) { e.printStackTrace(); } }