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)


Summary of Interfaces and Methods

Interface Method
DocumentErrorCallback void onerror(Error data);
DocumentInfo  
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);

1. Interfaces

1.1. DocumentErrorCallback

This callback interface defines the device information error callback.

Document::DocumentErrorCallback

  DocumentErrorCallback implements Document;

Methods

onerror
Callback parameter.

void onerror(Error data);

Product: B2B (LFD)

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

1.2. DocumentInfo

Document settings information object.

Document::DocumentInfo

Attributes

  • DOMStringDocumentInfo docpath
    Document file path.
  • long DocumentInforectX
    Document x coordinate.
  • long DocumentInforectY
    Document y coordinate.
  • long DocumentInforectWidth
    Document width value.
  • long DocumentInforectHeight
    Document height value.

1.3. DocumentManager

This interface provides methods to use Document functionalities.

Methods

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

DOMString getVersion();

Product: B2B (LFD)

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.

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(DocumentInfo docinfo, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror)
This interface provides a method to open a Document.

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

Product: B2B (LFD)

Parameters:

  • docinfo: Document basic information
  • onsuccess:Callback method to be invoked when this method executes successfully
  • onerror: 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.

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(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror)
This interface provides a method to close a playing Document.

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

Product: B2B (LFD)

Parameters:

  • onsuccess:Callback method to be invoked when this method executes successfully
  • onerror: 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.

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(long slideTime, DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror)
This interface provides a method to play a Document.

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

Product: B2B (LFD)

Parameters:

  • slideTime: Time spent on a slide, in seconds.
  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: 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.

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(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror)
This interface provides a method to stop Document playback.

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

Product: B2B (LFD)

Parameters:

  • onsuccess: Callback method to be invoked when this executes successfully.
  • onerror: 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.

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(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror)
This interface provides a method to move to the previous page of a Document.

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

Product: B2B (LFD)

Parameters:

  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: 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.

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(DocumentSuccessCallback onsuccess, optional DocumentErrorCallback? onerror)
This interface provides a method to move to the next page of a Document.

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

Product: B2B (LFD)

Parameters:

  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: 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.

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)

Parameters:

  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: 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.

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
ThThis interface provides a method to resume Document playback.

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

Product: B2B (LFD)

Parameters:

  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: 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
    • wwith the error type TypeMismatchError.

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)

Parameters:

  • onsuccess:Callback method to be invoked when this method executes successfully.
  • onerror: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
    • wwith the error type TypeMismatchError.

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)

Parameters:

  • page: Page to be moved to.
  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: 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.

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