Copy link to clipboard
Copied
Hi,
I have a case in which i have to select an annotation whithin APP_RENDERING_DONE event. The annotation is being selected but when I'm trying to call the goToLocation function within annotation selected event, nothing happens. In debug mode, everything works fine.
please advise...
Copy link to clipboard
Copied
When i add setTimeout, it works:
goToAnnotationLocation(annotation){
const PDFCoordinatePPI = 72;
const screenHeightInch = Math.round(screen.height / getPPI());
const page = parseInt(annotation.target.selector.node.index, 10) + 1;
const xCoordinate = parseInt(annotation.target.selector.boundingBox[0], 10);
const yCoordinate = (screenHeightInch * PDFCoordinatePPI) - parseInt(annotation.target.selector.boundingBox[3], 10);
console.log('before this.createAdobeViewerPromise');
this.createAdobeViewerPromise.then((view) => {
view.getAPIs().then((apis) => {
setTimeout(() => apis.gotoLocation(page, xCoordinate, yCoordinate - 5), 500);
}).catch((err) => Error.send(err.message, err.code, { failureLocation: 'PDF: Adobe embed sdk: getAPIs failed' }));
}).catch((err) => Error.send(err.message, err.code, { failureLocation: 'PDF: Adobe embed sdk: goToAnnotationLocation failed' }));
}
Copy link to clipboard
Copied
I'm glad you founsd something that works but the selectAnnotation API should shift the focus to the selected annotation automatically. You shouldn't have to even use goToLocation. Is that not working for you?
Copy link to clipboard
Copied
This is a workaround for a bug i reported to you guys. when PDF is in fit to width state and the page is longer than the screen. when i select an annotation programatically, it's not scrolling to the relevant annotation. That's why i added this.