This plugin allows a file contained in a JavaScript byte array or ArrayBuffer to be opened in an external app after prompting the user.
Opendoc.open("filename.pdf", pdf_data);
corodva plugin add com.collabitsoftware.opendoc
- Android
- iOS
var req = new XMLHttpRequest();
req.open('GET','https://mydomain/myfile.pdf');
req.responseType='arraybuffer';
req.onload=function() {if (req.status==200) {
let byteArray = new Uint8Array(req.response);
Opendoc.open("myfile.pdf", byteArray);
}
};
req.send();
-
filename (the filename including extension presented to the external app)
-
data (a byte array or ArrayBuffer)
-
mime_type (optional as type is auto-detected based on file extension, used on Android only)
-
success function (passed a json result string)
{
'type':'application/pdf',
'size':'123'
}
(type returned on Android only)
- failure function (never called)
Opendoc.open(
"document.pdf",
documentData,
"application/pdf",
(result) => console.log(result)
)