docViewer.on('rotationUpdated') not triggering

Product:
@pdftron/webviewer

Product Version:
7.2.0

Please give a brief summary of your issue:
docViewer.on(‘rotationUpdated’) not triggering after i set it.

Please describe your issue and provide steps to reproduce it:

Steps

  • Create a WebViewer instance.
  • Set the rotationUpdated handler on the docViewer.
  • Rotate a document

Expected
When the document is rotated it fires the handler that was set for that event.

Actual
Nothing happens.

These are screens of the code i used to set the handler and what i clicked to see it fire, the code of the handler is just console logging that the event was fired.



Hi,

The DocumentViewer#rotationUpdated event is for viewing rotation, however, the buttons highlighted in your screenshot are for changing the page rotation, which will be persisted in the download file. To trigger the DocumentViewer#rotationUpdated event, you need to use the Page Orientation buttons, as shown in the attached screenshot.

Wanbo

Screen Shot 2021-12-29 at 10.20.04 PM

Hi Wanbo, thank you for your reply it was very clarifying!, i had not picked that difference up from the documentation.

In regards to this:

So in my case we are letting the user view documents that are in an S3 and are readonly for them, is there an event i can listen for those buttons being clicked? I would at least like to add analytics to check if my users are pressing them.

Thank you again for your help.

Hi,

No problem.

You can listen to the layoutChanged event, code sample:

docViewer.addEventListener('layoutChanged', (e) => {
    console.log('layoutChanged');
    console.log(e);
  });

Thanks.

Wanbo

Are you sure the right event is “layoutChanged” ?
For me, “layoutChanged” did not work but it worked when I replaced it with “pagesUpdated”.

We renamed the layoutChanged API to pagesUpdated, please check the changelog here. Thanks.

Wanbo