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.
Solution 1:
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
Solution 2:
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
Solution 3:
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 = newbyte[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.
Post a Comment for "How To Load A Pdf File From The Assets Folder In Android"