My project in android use html file to navigate pages, and there is a link that will open a pdf file.
here is the html code for the html :
<a href="#" onClick="window.jsinterface.pdf1Click();" style="font-size: 0.9em; padding: 3px 7px 2px 7px; font-family:serif; color:white; text-decoration: none;">My PDF</a>
and this is the code for in my src.
public void pdf1Click() {
handler.post(new Runnable() {
public void run() {
ReadWriteDisplayPDFFile(getResources().openRawResource(R.raw.pdf1),"pdf1.pdf");
}
});
}
but when I run my project and click to the link to open the pdf file,
it can’t open the pdf file and i got this error:
Error Writting on /sdcard/myproj/pdf1.pdf
Please Inserd SD Card
and
No Application available to view pdf
does anyone have an Idea about my case?
thanks in advance
logcat:
Error writing /sdcard/myproj/pdf1.pdf
java.io.FileNotFoundException: /sdcard/myproj/pdf1.pdf : open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:416)
at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
at com.sample.AppActivity$JSInterface.ReadWriteDisplayPDFFile(AppActivity.java:146)
START {act=android.intent.action.VIEW dat=file:///sdcard/myproj/pdf1.pdf typ=application/pdf flg=0x4000000 u=0} from pid 626
Please see below Stack overflow’s answer for read pdf using pdfviewer library, it may help you and if you have any query regarding that then tell me.
Example of code to implement a PDF reader