android - How to convert a photo to pdf every time you click -


i'm working on app access , create folder after clicking access camera , after bit of photo shots, saving in latest in pdf. not know how turn jpg pdf. read itext not know how implement it

public class cameraview extends activity implements surfaceholder.callback{      protected static final string tag = null;      /* variabili private */     private surfaceview msurfaceview;     private surfaceholder msurfaceholder;     private camera mcamera;     private boolean mpreviewrunning;      /** called when activity first created. */     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          getwindow().setformat(pixelformat.transparent); //aggiungo il traslucido         requestwindowfeature(window.feature_no_title);  //no barra titolo         getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen);   //full screen          setcontentview(r.layout.main);          imagebutton buttonpicture = (imagebutton) findviewbyid(r.id.camera_surface_button);         buttonpicture.setonclicklistener(new onclicklistener(){             public void onclick(view v) {                  mcamera.takepicture(null, null, jpegcallback);             }         });          msurfaceview = (surfaceview)findviewbyid(r.id.camera_surface);         msurfaceholder = msurfaceview.getholder();  //recupero l'holder della surfaceview         msurfaceholder.addcallback(this);   //faccio la bind alla nostra activity         msurfaceholder.settype(surfaceholder.surface_type_push_buffers);    //tipo di surface, suggerito nei tutorial ufficiali     }      picturecallback jpegcallback = new picturecallback() {              public void onpicturetaken(byte[] data, camera camera) {                 //riparte la preview della camera                  file picturefile = getoutputmediafile(media_type_image);                 if (picturefile == null){                     throwable e = null;                     log.d(tag, "error creating media file, check storage permissions: " +                         e.getmessage());                     return;                 }                  try {                     fileoutputstream fos = new fileoutputstream(picturefile);                     fos.write(data);                     fos.close();                 } catch (filenotfoundexception e) {                     log.d(tag, "file not found: " + e.getmessage());                 } catch (ioexception e) {                     log.d(tag, "error accessing file: " + e.getmessage());                 }                  mcamera.startpreview();             }          };      @override     public void surfacechanged(surfaceholder arg0, int arg1, int arg2, int arg3) {         if (mpreviewrunning)             mcamera.stoppreview();          //setto le preferenze         camera.parameters p = mcamera.getparameters();  //prendo le preferenze della camera         p.setpreviewsize(arg2, arg3);         arraylist<size> list = (arraylist<size>) p.getsupportedpicturesizes();  //recuepro le risoluzioni supportate dalla camera         int picture_width = list.get(list.size()-1).width;         int picture_height = list.get(list.size()-1).height;         p.setpicturesize(picture_width, picture_height);    //setto la camera alla risoluzione pi bassa         p.setjpegquality(80);   // qualitˆ compressione jpeg          // salvo le pref         mcamera.setparameters(p);         try {             //lancio la preview             mcamera.setpreviewdisplay(arg0);             mcamera.startpreview();             mpreviewrunning = true;         } catch (ioexception e) {             //gestione errore         }     }      @override     public void surfacecreated(surfaceholder holder) {         mcamera = camera.open();      }      @override     public void surfacedestroyed(surfaceholder holder) {         mcamera.stoppreview();         mpreviewrunning = false;         mcamera.release();      }       public static final int media_type_image = 1;      final uri getoutputmediafileuri(int type){           return uri.fromfile(getoutputmediafile(type));     }      /** create file saving image or video */     final  file getoutputmediafile(int type){          string direct = this.getintent().getstringextra("key");          file mediastoragedir = new file(environment.getexternalstoragepublicdirectory(                   environment.directory_pictures ),direct );         // location works best if want created images shared         // between applications , persist after app has been uninstalled.          // create storage directory if not exist         if (! mediastoragedir.exists()){             if (! mediastoragedir.mkdirs()){                 log.d("mycameraapp", "failed create directory");                 return null;             }         }          // create media file name         string timestamp = new simpledateformat("yyyymmdd_hhmmss").format(new date());         file mediafile;          if (type == media_type_image){              mediafile = new file(mediastoragedir.getpath() + file.separator +                         "img_"+ timestamp + ".jpg");         }  else {             return null;         }          return mediafile;     }  } 

give me hand thanks

if have web server doing conversion, mpdf tcpdf fpdf


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -