Thanks Logan !
Please find the attached code to load the Webviewer instance.
wvInstance;
ngOnInit() {
this.wvDocumentLoadedHandler = this.wvDocumentLoadedHandler.bind(this);
this.detailsStepService.hasSubmittalId.subscribe(res => {
this.submittalId = res;
});
}
wvDocumentLoadedHandler(): void {
const docViewer = this.wvInstance;
const annotManager = this.wvInstance.annotManager;
const { Annotations } = this.wvInstance;
this.wvInstance.closeElements(['loadingModal']);
}
getDataById(info, id, index, instance?:any) {
console.log('instance 2', instance);
this.wvInstance = instance;
this.selectIndex = index;
console.log(info)
this.pdf_url = info
this.fileId = id
console.log(this.fileId)
this.wvInstance.openElements(['loadingModal']);
this.wvInstance.docViewer.loadDocument(info)
if (this.files.length > 1 && index != 0) {
console.log('files greater than 1');
this.sendForOCr();
}
}
async ngAfterViewInit(): Promise<void> {
WebViewer({
licenseKey: 'u4Utg1NNWOrQZIX32Rxu',
disableFlattenedAnnotations: true,
path: '../../wv-resources/lib',
config: '../../wv-resources/lib/ui/config/file.js', // relative to your HTML file
disabledElements: [
'selectToolButton', 'toolbarGroup-Edit', 'toolsHeader', 'searchButton', 'header',
'panToolButton', 'toggleNotesButton', 'notesPanel', 'menuButton', 'highlightToolGroupButton', 'underlineToolGroupButton', 'strikeoutToolGroupButton', 'stickyToolGroupButton', 'freeHandToolGroupButton',
'toolsOverlay', 'viewControlsButton', 'leftPanelButton', 'toolbarGroup-Insert', 'toolbarGroup-Shapes', 'squigglyToolGroupButton', 'freeTextToolGroupButton',
],
}, this.viewer.nativeElement).then(instance => {
console.log('instance 1', instance);
this.wvInstance = instance;
const tempSubmittalId = this.route.snapshot.queryParams['submittal'];
if (tempSubmittalId) {
this.submittalId = tempSubmittalId;
this.detailsStepService.changeSubmittalId(tempSubmittalId);
this.initiatePDFeditor(instance);
}
const utils = new ExpressUtils({
serverKey: '49EzA6YczS1pfUG7ZYZy',
clientKey: '0U7UA9kWPkFSfX3iQNB5'
})
const { Annotations, Tools, annotManager, docViewer } = instance;
// set pdf to full width of viewer
instance.setFitMode(instance.FitMode.FitWidth);
)}
}
initiatePDFeditor(instance?:any) {
this.fileUploadService.getDataById(this.submittalId).subscribe(res => {
this.files = res;
for (let file of this.files) {
file["active"] = false;
}
if (this.files.length > 0) {
this.getDataById(this.files[0].file_info, this.files[0].id, 0, instance);
}
}, err => {
const error = err.error || 'Server Error';
this.openSnackBar(error);
});
}