Hello good morning, I have a problem, I need to show a pdf encoded in base64 which I get from a webservice, the detail is that I can not figure out how to decode it and show it with PdfRender in the method that is supposed to show it , the example is made with a pdf already loaded in the assets folder, but I want to show it according to the base64 that I am getting, if you can guide me please I will thank you very much, thank you.
fileBase64Encode: is the base64 pdf that I get from the service but hence I no longer know how to treat it.
private void openRenderer(Context context, String fileBase64Encode) throws IOException {
File file = new File(context.getCacheDir(), FILENAME);
if (!file.exists()) {
// Since PdfRenderer cannot handle the compressed asset file directly, we copy it into
// the cache directory.
InputStream asset = context.getAssets().open(FILENAME);
FileOutputStream output = new FileOutputStream(file);
final byte[] buffer = new byte[1024];
int size;
while ((size = asset.read(buffer)) != -1) {
output.write(buffer, 0, size);
}
asset.close();
output.close();
}
mFileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
// This is the PdfRenderer we use to render the PDF.
if (mFileDescriptor != null) {
mPdfRenderer = new PdfRenderer(mFileDescriptor);
}
}