The callback function that always fires if the loadFromUri operation fails.
Object.defineProperty(LoadFromUriParams.prototype, 'failCallback',
get: function(),
set: function(value)
)
Default value is null. If a valid function is provided, this callback fires if the Viewer.loadFromLocal operation fails. This function will be passed a ServiceError containing the error information.
export class ViewerLoadFromUriExample {
private _viewer: lt.LEADVIEW.Viewer = null;
private _demoUrl = 'https://demo.leadtools.com/images/pdf/leadtools.pdf';
public constructor() {
if(lt.RasterSupport.kernelExpired)
lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null);
}
public run = (divID: string, setButtonId: string): void => {
const lv = new lt.LEADVIEW.Viewer();
// Builds a new instance of LEADVIEW.
// For the full list of options that can be passed to the run method,
// refer to the settings JSON files that are included in the LEADVIEW demo application.
// Settings files can also be generated from the LEADVIEW application itself.
lv.run(null, {
'rootDivId': divID,
'showMainMenu': false,
'serviceHost': 'http://localhost:40000', // or wherever your host is
'servicePath': '', // the path to the root of the service, which is nothing for this example
'serviceApiPath': 'api', // Routing occurs at "/api", unless you change the routing in the DocumentsService
});
this._viewer = lv;
document.getElementById(setButtonId).onclick = this.setCurrentDocument;
}
private setCurrentDocument = () => {
const loadOptions: lt.LEADVIEW.ILoadFromUriParams = {
url: this._demoUrl,
loadOptions: null,
loadingDialogCallback: null,
successCallback: (document: lt.Document.LEADDocument) => {
this._viewer.getDocumentViewer().setDocument(document);
},
alwaysCallback: null,
failCallback: this.errorHandler
}
this._viewer.loadFromUri(loadOptions);
}
private errorHandler = (serviceError: lt.Document.ServiceError) => {
alert(`There was an error loading in the document. ${serviceError.message}`);
}
}