MuPDFViewer icon indicating copy to clipboard operation
MuPDFViewer copied to clipboard

can you help me

Open houssine20 opened this issue 11 years ago • 1 comments

I want to read a pdf file from assets folder

Thanks...

houssine20 avatar Apr 17 '14 21:04 houssine20

In ChoosePDFActivity in this onListItemClick method, you can find some codes like this

Uri uri = Uri.parse(mFiles[position].getAbsolutePath());
......
intent.setData(uri);

at line 208, you can copy the file from assets folder to SD and then read the pdf file from sd. You can use these codes to copy file from assets to sd

private void copyDBToSD() {
    InputStream myInput;
    OutputStream myOutput;
    try {
        myOutput = new FileOutputStream(
                Environment.getExternalStorageDirectory() + "/"
                        + "filename.pdf");
        myInput = this.getAssets().open("filename.pdf");
        byte[] buffer = new byte[1024];
        int length = myInput.read(buffer);
        while (length > 0) {
            myOutput.write(buffer, 0, length);
            length = myInput.read(buffer);
        }

        myOutput.flush();
        myInput.close();
        myOutput.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

liumeng1201 avatar Jul 24 '14 09:07 liumeng1201