addFileWithAuthentication(string,function,function) Method
In This Topic
Sends an asynchronous request to a server, gets information (with file authentication) about images, which are stored in file on server and adds images to the web document viewer.
Syntax
var instance = new Vintasoft.Imaging.UI.WebDocumentViewerBaseJS(settings);
var value; // Type: any
// Parameters
var fileId; // Type: string
var successFunc; // Type: function
var errorFunc; // Type: function
value = instance.addFileWithAuthentication(fileId, successFunc, errorFunc);
function addFileWithAuthentication(
: string,
: Function,
: Function
) : any;
Parameters
- fileId
- A string, which represents the file identifier.
- successFunc
- Function that will be executed if request is executed successfully.
Here is function prototype "function __success(data)".
The data parameter has the following properties:
- imageInfos (object): Information about images in image file.
- isAuthenticationRequired (boolean): A value indicating whether current image file requres authentication.
- images (object): An array of WebImageJS objects created using imageInfos property.
- errorFunc
- Function that will be executed if request is failed.
Here is function prototype "function __error(data)".
The data parameter can be:
- An object with following properties:
- errorMessage (string): Error message.
- blocked (boolean): Indicates that the requested action is blocked by another request.
if exception is catched inside web service. - Otherwise, jqXHR object.
Remarks
The method raises the fileOpened event if file is opened successfully.
Example
ThisJavaScriptcodeshowshowtoopenfile,whichisstoredonserverandhavepassword,inwebdocumentviewer:
// add file with authentication - the web document viewer will show the password dialog to enter the password to a file if file needs authentication
docViewer1.addFileWithAuthentication(
"pdfDocumentWithPassword.pdf",
function(data) {
console.log("File is opened successfully.");
},
function(data) {
console.log("File is not opened.");
}
);
Browser Compatibility
See Also