#Appcelerator PDF Viewer Demo
This sampe app demonstrates how to view PDF files from the web and from local application resource on iOS and Android
The PDFs used in this demo are:
-
Resource PDF - stored in the /app/assets/pdf folder - "the Best of Wikipedia's Worst Writing"
-
Web hosted PDF - MBTA Map - https://www.mbta.com/uploadedfiles/Documents/Schedules_and_Maps/Rapid%20Transit%20w%20Key%20Bus.pdf
-
Use DocumentViewer on iOS and external app (via Intent) on Android
-
For iOS and Android the PDF file should be stored on the file system before viewing - for Android use SDCard (external storage)
-
Make sure you have a PDF viewer installed on your Android device or emulator
The demo uses the FileSystem exists() method to see if the file has been downloaded from the web (on both iOS and Android) and copied to external memory (on Android). This is optional.
##iPhone Screen Shots:
##Android Screen Shots:
allow app to access photos, media and files on your device. For that,
function openURLPDF {
var hasStoragePermissions = Ti.Filesystem.hasStoragePermissions();
/*
your code
*/
if(hasStoragePermissions){
/*
check the appFile.exists() or not (Check if file has been downloaded yet)
*/
}else{
Ti.Filesystem.requestStoragePermissions(function(e){
if(e.success){
openURLPDF();
}else{
var dialog = Ti.UI.createAlertDialog({
message : 'Oops! try again'
});
dialog.show();
}
});
}
}