I am working on an Android project where I have a PDF file as byte array. My goal is to render this PDF file and show to user in my application (without calling any other third-party PDF viewer).
For security reasons, even temporarily, I am not allowed to create file in phone directory.
Android 5.0, came with a PdfRenderer library where you pass FileDescriptor, but I can't use it. Is there any way to achieve this?
EDIT:
@Deprecated
public static ParcelFileDescriptor fromData(byte[] data, String name) throws IOException {
if (data == null) return null;
MemoryFile file = new MemoryFile(name, data.length);
if (data.length > 0) {
file.writeBytes(data, 0, 0, data.length);
}
file.deactivate();
FileDescriptor fd = file.getFileDescriptor();
return fd != null ? new ParcelFileDescriptor(fd) : null;
}
Thanks