Document API Usage

This document describes new usages of Samsung Product Document API for Tizen 6.5 and higher, and differences with the SSSP B2BDoc API.


Related Info


Generals

  • Privilege: http://developer.samsung.com/privilege/documentplay
  • Privilege level: Partner

API Usages

webapis.document.getVersion

This interface provides methods to get doc module's version.

  • SSSP API sample code:

    var Version = null; 
    
    try {
      Version = b2bapis.b2bdoc.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); 
    }
    
  • Samsung Product API sample code:

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

webapis.document.open

Prepare the document to play and set the necessary values for play.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[openDoc] success : " + val); 
        };
    var onError = function(error) {
      console.log("[openDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
        };
    
    console.log("[openDoc]");
    b2bapis.b2bdoc.openDoc("http://<IP>/1.PDF", 1000, 500, 800, 500, onSuccess, onError);
    
  • Samsung Product API sample code:

    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://<IP>/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);
    }
    

webapis.document.close

This interface provides methods to close doc play.

  • SSSP API sample code:

    var onSuccess = function(val) {
        console.log("[closeDoc] success : " + val); 
    	};
    var onError = function(error) {
        console.log("[closeDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
    	};
    
    console.log("[closeDoc]");
    b2bapis.b2bcontrol.closeDoc(onSuccess, onError);
    
  • Samsung Product API sample code:

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

webapis.document.play

This interface provides methods to play document.

  • SSSP API sample code:

    var onSuccess = function(val) {
        console.log("[playDoc] success : " + val); 
        };
    var onError = function(error) {
        console.log("[playDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
        };
    
    console.log("[playDoc]");
    b2bapis.b2bdoc.playDoc(5, onSuccess, onError); // First parameter defines page slide time
    
  • Samsung Product API sample code:

    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); // First parameter defines page slide time
    } catch (e) {
        console.log("[play] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.document.stop

This interface provides methods to stop doc play.

  • SSSP API sample code:

    var onSuccess = function(val) {
        console.log("[stopDoc] success : " + val); 
      };
    var onError = function(error) {
      console.log("[stopDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
    
    console.log("[stopDoc] ");
    b2bapis.b2bdoc.stopDoc(onSuccess, onError);
    
  • Samsung Product API sample code:

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

webapis.document.pause

This interface provides methods to pause document.

  • SSSP API sample code:

    var onSuccess = function(val) {
        console.log("[pauseDoc] success : " + val); 
        };
    var onError = function(error) {
        console.log("[pauseDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
        };
      
    console.log("[pauseDoc] ");
    b2bapis.b2bdoc.pauseDoc(onSuccess, onError);
    
  • Samsung Product API sample code:

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

webapis.document.resume

This interface provides methods to resume document play.

  • SSSP API sample code:

    var onSuccess = function(val) {
        console.log("[resumeDoc] success : " + val); 
        };
    var onError = function(error) {
      console.log("[resumeDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
        };
      
    console.log("[resumeDoc] ");
    b2bapis.b2bdoc.resumeDoc(onSuccess, onError);
    
  • Samsung Product API sample code:

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

webapis.document.prevPage

This interface provides methods to navigate to previous page of document.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[prevPageDoc] success : " + val); 
      };
    var onError = function(error) {
      console.log("[prevPageDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
      
    console.log("[prevPageDoc] ");
    b2bapis.b2bdoc.prevPageDoc(onSuccess, onError);
    
  • Samsung Product API sample code:

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

webapis.document.nextPage

This interface provides methods to navigate to next page of document.

  • SSSP API sample code:

    var onSuccess = function(val) {
        console.log("[nextPageDoc] success : " + val); 
        };
    var onError = function(error) {
        console.log("[nextPageDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
        };
      
    console.log("[nextPageDoc] ");
    b2bapis.b2bdoc.nextPageDoc(onSuccess, onError);
    
  • Samsung Product API sample code:

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

webapis.document.gotoPage

Go to page directly.

  • SSSP API sample code:

    var onSuccess = function(val) {
      console.log("[gotoPageDoc] success : " + val); 
      };
    var onError = function(error) {
      console.log("[gotoPageDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
      };
      
    console.log("[gotoPageDoc] ");
    b2bapis.b2bdoc.gotoPageDoc(3, onSuccess, onError); // First parameter is page number
    
  • Samsung Product API sample code:

    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); // First parameter is page number
    } catch (e) {
        console.log("[gotoPage] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    

webapis.document.setDocumentOrientation

This interface provides methods to display document vertically.

  • SSSP API sample code:

    var onSuccess = function(val) {
        console.log("[setVerticalDoc] success : " + val); 
      };
    var onError = function(error) {
      console.log("[setVerticalDoc] code :" + error.code + " error name: " + error.name + " message " + error.message);
        };
      
    console.log("[setVerticalDoc] ");
    b2bapis.b2bdoc.setVerticalDoc(onSuccess, onError);
    
  • Samsung Product API sample code:

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