How to load a pdf file from the assets folder in android
I'm 开发者_运维问答a new bee in android programming. Do you have any ideas on how to read a PDF file programmatically if the file is from the assets directory?Any help would be appreciated.
I have never tried it myself but there are many good tutorials out there. Try this http://thedevelopersinfo.com/2009/11/17/using-assets-in-android/
Reading pdf or any file is similar. Try googling more about "reading files from asset folder" if the tutorial above does not help you
you can use iText for reading pdf.
There is a link : http://www.vogella.de/articles/JavaPDF/article.html note : in above link they have used path of the file on pc like c:/documents/temp.pdf on the place of same give path of ur SDcard or asset.
Hope this may help u, Try to search on net u will definitely get some stuff.... All The Best
This is how you read pdf file from assets folder and save it to your SDCard :
AssetManager is = this.getAssets();
InputStream fis = is.open("excerpt.pdf");
FileOutputStream fos = new FileOutputStream(
new File(Environment.getExternalStorageDirectory(), "excerpt_DEC.pdf"));
byte[] b = new byte[8];
int i;
while ((i = fis.read(b)) != -1) {
fos.write(b, 0, i);
}
fos.flush(); fos.close();
fis.close();
You can change the save destination if you want.
精彩评论