Reputation: 3273
I want to be able to open a pdf file from my application without any other application like pdf viewer. I don't want to make the user install an other appliation to open pdf files. Is there any open source library that I can use in my project?
Upvotes: 3
Views: 3230
Reputation: 31
You can open a PDF in a webview using google docs. The URL format is
https://docs.google.com/gview?embedded=true&url=http://link.to.your/yourfile.pdf
or you can open pdf using pdf viewer Follow this code
FileFinalpath = SdCardpath + "/" + Filepath + Filename;
File file = new File(FileFinalpath);
if (file.exists()) {
Uri filepath = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(filepath, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
} catch (Exception e) {
alert.showAlertDialog(PDF_Activity.this, "File Not Started...","File Not Started From SdCard ", false);
Log.e("error", "" + e);
}
} else {
alert.showAlertDialog(PDF_Activity.this, "File Not Found...","File Not Found From SdCard ", false);
}
Upvotes: 0
Reputation: 20936
You can use, for instance, MuPdf Reader. I described how to build it here.
Upvotes: 2
Reputation: 21567
You can open a PDF in a webview using google docs. The URL format is
https://docs.google.com/gview?embedded=true&url=http://link.to.your/pdf_file.pdf
Upvotes: 3