The callback function that always fires after the loadFromLocal operation has finished.
Object.defineProperty(LoadFromLocalParams.prototype, 'loadAlwaysCallback',
get: function(),
set: function(value)
)
Default value is null. If a valid function is provided, this callback fires after the Viewer.loadFromLocal operation has finished.
export class ViewerLoadFromLocalExample {
private _viewer: lt.LEADVIEW.Viewer = null;
private _file: File = null;
public constructor() {
if(lt.RasterSupport.kernelExpired)
lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null);
}
public run = (divID: string, buttonID: 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(buttonID).onchange = this.onFileChange;
}
private onFileChange = (event: any) => {
this._file = (event.target.files.length === 0) ? null : event.target.files[0];
if(this._file)
this.loadFromLocal();
}
private loadFromLocal = () => {
const loadOptions:lt.LEADVIEW.ILoadFromLocalParams = {
file: this._file,
annFile: null,
loadFailCallback: this.errorHandler,
uploadFailCallback: this.errorHandler,
loadOptions: null,
loadingDialogCallback: null,
loadAlwaysCallback: null,
loadSuccessCallback: (document: lt.Document.LEADDocument) => {
this._viewer.getDocumentViewer().setDocument(document);
},
uploadProgressCallback: null,
uploadSuccessCallback: null
};
this._viewer.loadFromLocal(loadOptions);
}
private errorHandler = (serviceError: lt.Document.ServiceError) => {
alert(`There was an error loading in the document. ${serviceError.message}`);
}
}