how do i show pdf in my own android application -


i have text can please tell me how convert text pdf , how show in android application. saw there many libraries same can 1 give me sample code that. thanks

i have used pdfviewer lib still didnt pdf. hear code -

    file images = environment.getexternalstoragedirectory();     imagelist = images.listfiles(new filenamefilter()     {               public boolean accept(file dir, string name)               {                       return ((name.endswith(".pdf")));             }       });      pdflist = new string[imagelist.length];      for(int = 0;i<imagelist.length;i++)     {             pdflist[i] = imagelist[i].getname();     }     this.setlistadapter(new arrayadapter<string>(this,android.r.layout.simple_list_item_1, pdflist)); }  @override protected void onlistitemclick(listview l, view v, int position, long id)  {         super.onlistitemclick(l, v, position, id);         string path = imagelist[(int)id].getabsolutepath();         openpdfintent(path); }  private void openpdfintent(string path)  {     try     {       final intent intent = new intent(this, second.class);       intent.putextra(pdfvieweractivity.extra_pdffilename, path);       startactivity(intent);     }     catch (exception e)      {       e.printstacktrace();     } } 

}

add pdfviewer library in project, copy resources in guided in here. working code me. reading pdf assets folder. customization requirement.

  1. download pdf reader project above link.
  2. copy resources in project.
  3. extend activity (in want display pdf) pdfvieweractivity.
  4. copy methods pdfreader project in yourpdfview activity.
  5. run.

happy coding

assetmanager assetmanager = getassets(); inputstream in = null; outputstream out = null; file file = new file(getfilesdir(), "abc.pdf");   try {     in = assetmanager.open("abc.pdf");     out = openfileoutput(file.getname(), context.mode_world_readable);      copyfile(in, out);     in.close();     in = null;     out.flush();     out.close();     out = null;   } catch (exception e) {     log.e("tag", e.getmessage());   }    intent intent = new intent(this, yournextactivityname.class);   intent.putextra(pdfvieweractivity.extra_pdffilename, getfilesdir() + "/abc.pdf");   startactivity(intent); }  private void copyfile(inputstream in, outputstream out) throws ioexception {   byte[] buffer = new byte[1024];   int read;   while ((read = in.read(buffer)) != -1) {     out.write(buffer, 0, read);   } } 

the methods of yourpdfview activity are:

public int getpreviouspageimageresource() { return r.drawable.left_arrow; } public int getnextpageimageresource() { return r.drawable.right_arrow; } public int getzoominimageresource() { return r.drawable.zoom_in; } public int getzoomoutimageresource() { return r.drawable.zoom_out; } public int getpdfpasswordlayoutresource() { return r.layout.pdf_file_password; } public int getpdfpagenumberresource() { return r.layout.dialog_pagenumber; } public int getpdfpasswordeditfield() { return r.id.etpassword; } public int getpdfpasswordokbutton() { return r.id.btok; } public int getpdfpasswordexitbutton() { return r.id.btexit; } public int getpdfpagenumbereditfield() { return r.id.pagenum_edit; } 

Comments