开发者

How to read Pdf in Android without using 3rd party apps?

i have used Itext and Pdf renderer library files to read the Pdf files in java.. but i开发者_Go百科n android i have used Same libraries reading pdf files is possible but i'm unable to display the file..

how to display the pd ffile in the emulator???

File sdcard = Environment.getExternalStorageDirectory();
        Log.v("Tag:","entered sdcard");
        String input = "/sdcard/andr.pdf";
        Log.v("Tag:","file  recog");

//        File file = new File(sdcard, input);





        try {
//   PdfWriter write = new PdfWriter();

   PdfReader read = new PdfReader(input);
   Log.v("Tag","reading------------"+read.getPageN(9).toString());
//   fl.addView((View)read);
   Log.v("Tag page",read.getPageN(5).getKeys().toString());
//   PdfStream pdfd=new PdfStream(is, write);
   read.getCatalog();

   Log.v("Catalog",read.getCatalog().toString());



   Log.v("Tag:","pdf opened");
   System.gc();
   int n = read.getNumberOfPages();
   Integer num=n;
   Log.v("Tag:",num.toString() );
   Log.v("Tag:","got pages");

//   int n1 = read.getFileLength();
//   
//   Integer num1 = n1;
//   Log.v("tag", num1.toString());


   for(int i=0;i <=1;i++){
//   tv.setText((CharSequence) page);

   read.getPageSize(1);
   Log.v("tag", "page size"+read.getPageSize(1).toString());



    Log.v("Tag:","got pages");



    wv = new WebView(this); 
    setContentView(wv); 
//    wv.getSettings().setJavaScriptEnabled(true);

//    wv.loadUrl("/sdcard/andr.pdf");



   }

  } 
        catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
    }


Once you manipulate the PDF, save it and See: How to render PDF in Android

Just take the method body from onClick in the answer and call it when you're done writing the PDF.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜