1.0.4 • Published 3 years ago

com.collabitsoftware.opendoc v1.0.4

Weekly downloads
126
License
BSD-3-Clause
Repository
-
Last release
3 years ago

title: OpenDoc

description: Launch a document in an external app

OpenDoc

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);

Installation

corodva plugin add com.collabitsoftware.opendoc

Supported Platforms

  • Android
  • iOS

Quick example

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();

Parameters

  • 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)

Further Example

Opendoc.open(
	"document.pdf",
	documentData,
	"application/pdf",
	(result) => console.log(result)
)