Retrieves an array containing all the document IDs that are currently loaded into the Viewer.
An array of strings corresponding to all the IDs that were found. If the run method has not been called, or if a file is not loaded into the Viewer, then an empty array is returned.
export class ViewerGetIdsExample {
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/v200/LEADTOOLSEVAL.txt", "EVAL", null);
}
public run = (divID: string, setButtonID: string, getButtonID: 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;
document.getElementById(getButtonID).onclick = this.getIds;
}
private setCurrentDocument = () => {
lt.Document.DocumentFactory.loadFromUri(this._demoUrl, null).done((document) => {
this._viewer.setCurrentDocument(document);
}).fail((jqXHR, statusText, errorThrown) => {
const serviceError = lt.Document.ServiceError.parseError(jqXHR, statusText, errorThrown);
alert(`There was an error loading in the document. ${serviceError.message}`);
});
}
private getIds = () => {
const ids = this._viewer.getIds();
alert(`Current ID's: ${ids}`);
}
}