convert base64 to pdf object for pdf reader in android studio

Solutions on MaxInterview for convert base64 to pdf object for pdf reader in android studio by the best coders in the world

showing results for - "convert base64 to pdf object for pdf reader in android studio"
Nico
10 Nov 2018
1 case PDF:
2    try {
3        byte[] pdfAsBytes = Base64.decode(file.getContent(), Base64.DEFAULT);
4        File dir = getStorageDir();
5        File pdffile = new File(dir, file.getName());
6        if(!pdffile.exists())
7        {
8            pdffile.getParentFile().mkdirs();
9            pdffile.createNewFile();
10        }
11        Files.write(pdfAsBytes, pdffile);
12        Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
13        pdfIntent.setDataAndType(Uri.fromFile(pdffile), "application/pdf");
14        pdfIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
15        startActivity(pdfIntent);
16    } catch (IOException e) {
17        e.printStackTrace();
18    }
19
20    break;
21