Document API

To use Samsung Product API,

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

This module defines the Document functionalities provided by the Tizen Samsung Product API.

Since : 6.5

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Summary of Interfaces and Methods

Interface Method
DocumentInfo

DocumentManagerObject

DocumentManager

DOMString getVersion();
void open(DocumentInfo docinfo, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void close(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void play(long slideTime, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void stop(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void prevPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void nextPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void pause(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void resume(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void setDocumentOrientation(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
void gotoPage(long page, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

DocumentSuccessCallback

void onsuccess(Result data);

DocumentErrorCallback

void onerror(Error data);

1. Type Definitions

1.1 Result

Stores the results and information of successful callbacks

dictionary Result {
  DOMString result;
  DOMString data;
};

The following values are supported

  • result : Result of the successful callback
  • data : Saved data of the callback result

1.2 Error

Error value of a callback function

dictionary Error {
  DOMString code;
  DOMString name;
  DOMString message;
};

The following values are supported

  • code : Error code
  • name : Error name
  • message : Error message

2. Interfaces

2.1 DocumentInfo

Document settings information object

[NoInterfaceObject] interface DocumentInfo {
  attribute DOMString docpath;
  attribute long rectX;
  attribute long rectY;
  attribute long rectWidth;
  attribute long rectHeight;
};

Attributes

  • DOMString docpath
    Document file path
  • long rectX
    Document x coordinate
  • long rectY
    Document y coordinate
  • long rectWidth
    Document width value
  • long rectHeight
    Document height value

2.2 DocumentManagerObject

This interface defines what is instantiated by the Document object of Tizen Samsung Product API.
A webapis.document object allows access to the functionality of the Document API

[NoInterfaceObject] interface DocumentManagerObject {
  readonly attribute DocumentManager document;
};
WebApi implements DocumentManagerObject;

Attributes

2.3 DocumentManager

This interface provides methods to use Document functionalities.

[NoInterfaceObject] interface DocumentManager {
  DOMString getVersion();
  void open(DocumentInfo docinfo, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void close(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void play(long slideTime, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void stop(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void prevPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void nextPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void pause(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void resume(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void setDocumentOrientation(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  void gotoPage(long page, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
};

Methods

getVersion

This interface provides a method to get a Document module's version.

DOMString getVersion();

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Return Value :

  • DOMString : Version of the Document module

Exceptions :

  • WebAPIException
    • with the error type SecurityError if the application does not have the privilege to call this method
    • with the error type UnknownError in any other error case

Since : 6.5

Code Example :

var Version = null;

try {
  Version = webapis.document.getVersion();
} catch (e) {
  console.log("[getVersion] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

if (null !== Version) {
  console.log("[getVersion] call syncFunction type: " + Version);
}

open

Prepare the Document for playing and setting the necessary values for the play operation.

void open(DocumentInfo docinfo, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • docinfo : Document basic information
  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[open] success : " + val);
};

var onerror = function(error) {
  console.log("[open] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

var docinfo = {
  "docpath"    : "http://107.109.202.6:80/1.PDF",
  "rectX"      : 0,
  "rectY"      : 0,
  "rectWidth"  : 960,
  "rectHeight" : 540
};

try {
  webapis.document.open(docinfo, onsuccess, onerror);
} catch (e) {
  console.log("[open] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

close

This interface provides a method to close a playing Document.

void close(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[close] success : " + val);
};

var onerror = function(error) {
  console.log("[close] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.close(onsuccess, onerror);
} catch (e) {
  console.log("[close] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

play

This interface provides a method to play a Document.

void play(long slideTime, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • slideTime : Time spent on a slide, in seconds
  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[play] success : " + val);
};

var onerror = function(error) {
  console.log("[play] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.play(5, onsuccess, onerror);
} catch (e) {
  console.log("[play] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

stop

This interface provides a method to stop Document playback.

void stop(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • onsuccess : Callback method to be invoked when this executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[stop] success : " + val);
};

var onerror = function(error) {
  console.log("[stop] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.stop(onsuccess, onerror);
} catch (e) {
  console.log("[stop] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

prevPage

This interface provides a method to move to the previous page of a Document.

void prevPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[prevPage] success : " + val);
};

var onerror = function(error) {
  console.log("[prevPage] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.prevPage(onsuccess, onerror);
} catch (e) {
  console.log("[prevPage] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

nextPage

This interface provides a method to move to the next page of a Document.

void nextPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[nextPage] success : " + val);
};

var onerror = function(error) {
  console.log("[nextPage] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.nextPage(onsuccess, onerror);
} catch (e) {
  console.log("[nextPage] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

pause

This interface provides a method to pause Document playback.

void pause(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[pause] success : " + val);
};

var onerror = function(error) {
  console.log("[pause] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.pause(onsuccess, onerror);
} catch (e) {
  console.log("[pause] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

resume

This interface provides a method to resume Document playback.

void resume(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[resume] success : " + val);
};

var onerror = function(error) {
  console.log("[resume] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.resume(onsuccess, onerror);
} catch (e) {
  console.log("[resume] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

setDocumentOrientation

This interface provides a method for vertical Document playback.

void setDocumentOrientation(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[setDocumentOrientation] success : " + val);
};

var onerror = function(error) {
  console.log("[setDocumentOrientation] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.setDocumentOrientation(onsuccess, onerror);
} catch (e) {
  console.log("[setDocumentOrientation] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

gotoPage

This interface provides a method to go to a specified page.

void gotoPage(long page, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • page : Page to be moved to
  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : Callback method to be invoked when an error occurs
    The error type is SecurityError if the application does not have the privilege to call this method.
    The error type is UnknownError in any other error case.

Exceptions :

  • WebAPIException
    • with the error type TypeMismatchError

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[gotoPage] success : " + val);
};

var onerror = function(error) {
  console.log("[gotoPage] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.gotoPage(3, onsuccess, onerror);
} catch (e) {
  console.log("[gotoPage] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

2.4 DocumentSuccessCallback

This callback interface defines the device information success callback.

[Callback = FunctionOnly, NoInterfaceObject] interface DocumentSuccessCallback {
  void onsuccess(Result data);
};

Methods

onsuccess

Callback parameter

void onsuccess(Result data);

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • data : Status of the operation

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[gotoPage] success : " + val);
};

var onerror = function(error) {
  console.log("[gotoPage] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};

try {
  webapis.document.gotoPage(3, onsuccess, onerror);
} catch (e) {
  console.log("[gotoPage] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

2.5 DocumentErrorCallback

This callback interface defines the device information error callback.

[Callback = FunctionOnly, NoInterfaceObject] interface DocumentErrorCallback {
  void onerror(Error data);
};

Methods

onerror

Callback parameter.

void onerror(Error data);

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/documentplay

Parameters :

  • data : Status of the operation

Since : 6.5

Code Example :

var onsuccess = function(val) {
  console.log("[gotoPage] success : " + val);
};
var onerror = function(error) {
  console.log("[gotoPage] code :" + error.code + " error name: " + error.name + "  message " + error.message);
};
try {
  webapis.document.gotoPage(3, onsuccess, onerror);
} catch (e) {
  console.log("[gotoPage] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

3. Full WebIDL

module Document {
  dictionary Result {
    DOMString result;
    DOMString data;
  };

  dictionary Error {
    DOMString code;
    DOMString name;
    DOMString message;
  };

  [NoInterfaceObject] interface DocumentInfo {
    attribute DOMString docpath;
    attribute long rectX;
    attribute long rectY;
    attribute long rectWidth;
    attribute long rectHeight;
  };

  [NoInterfaceObject] interface DocumentManagerObject {
    readonly attribute DocumentManager document;
  };

  WebApi implements DocumentManagerObject;

  [NoInterfaceObject] interface DocumentManager {
    DOMString getVersion();
    void open(DocumentInfo docinfo, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void close(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void play(long slideTime, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void stop(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void prevPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void nextPage(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void pause(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void resume(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void setDocumentOrientation(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
    void gotoPage(long page, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror);
  };

  [Callback = FunctionOnly, NoInterfaceObject] interface DocumentSuccessCallback {
    void onsuccess(Result data);
  };

  [Callback = FunctionOnly, NoInterfaceObject] interface DocumentErrorCallback {
    void onerror(Error data);
  };

};