axeld
June 29, 2023, 1:41pm
1
Hello,
Document2.pdf (76.7 KB)
Promise is never resolved if pdf contains a blank page.
On version 8.7.4 the problem is here. It worked well on 8.7.0
Core.documentViewer.addEventListener('documentLoaded', async () => {
await initAnnotate();
});
const initAnnotate = () => {
console.log('initAnnotate');
return new Promise(resolve => {
const searchMode = Core.Search.Mode.REGEX | Core.Search.Mode.HIGHLIGHT | Core.Search.Mode.PAGE_STOP;
const searchOptions = {
fullSearch: true, // search the full document,
onResult: (result) => {
console.log('onResult');
},
onDocumentEnd: () => {
console.log('onDocumentEnd');
resolve();
}
}
let searchText = "test";
Core.documentViewer.textSearchInit(searchText, searchMode, searchOptions);
});
}
Hello axeld,
Can you try handling the onError, onResult, and onPageEnd callbacks? There could be an error that is occurring.
Best regards,
Tyler
axeld
June 30, 2023, 9:11am
4
Hello tgordon,
I already tried to log those callbacks, no errors reported. Plus, 8.7.0 works well.
Hi axeld,
Loading the code you provided I see the promise resolve, I modified the resolve to include some text to log. It logs in the console correctly.
const { documentViewer, Annotations } = instance.Core;
const annotationManager = documentViewer.getAnnotationManager();
documentViewer.addEventListener('documentLoaded', async () => {
initAnnotate().then((value)=>{
console.log(value)
})
});
const initAnnotate = () => {
console.log('initAnnotate');
return new Promise(resolve => {
const searchMode = instance.Core.Search.Mode.REGEX | instance.Core.Search.Mode.HIGHLIGHT | instance.Core.Search.Mode.PAGE_STOP;
const searchOptions = {
fullSearch: true, // search the full document,
onResult: (result) => {
console.log('onResult');
},
onDocumentEnd: () => {
console.log('onDocumentEnd');
resolve('documentEnd');
}
}
let searchText = "test";
documentViewer.textSearchInit(searchText, searchMode, searchOptions);
});
}
Best regards,
Tyler
axeld
July 17, 2023, 1:44pm
6
Ok my bad, I uploaded the wrong document. Can you try with this one ?
lastpage.pdf (29.0 KB)
I copy/paste your code, and the promise is never resolved. I also tried onError callback, and nothing is logged.
8.7.0 still working with this document, but not 8.7.4.
Thanks.
Hello axeld,
I was able to reproduce the issue with the new file provided, I have added this as a bug report to our backlog to be reviewed by our product team. Thank you!
Best regards,
Tyler
axeld
July 26, 2023, 11:57am
8
Thanks for the answer, have a good day :).