我使用了Itext和Pdf渲染器库文件来读取java中的Pdf文件。 但在android中我使用相同的库读取pdf文件是可能的,但我无法显示文件..
如何在模拟器中显示pd ffile ???
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();
}