Skip to main content
Known Participant
September 19, 2021
Question

Adobe pdf embed- goToLocation timing problem

  • September 19, 2021
  • 1 reply
  • 812 views

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...

    This topic has been closed for replies.

    1 reply

    Alon5FCDAuthor
    Known Participant
    September 19, 2021

    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' }));
    }
    Joel Geraci
    Community Expert
    Community Expert
    September 20, 2021

    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?

    Alon5FCDAuthor
    Known Participant
    September 22, 2021

    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.