Annotation resizing gone wrong for pdf pages in landscape mode

WebViewer Version: 10.10.0

Do you have an issue with a specific file(s)? yes
Can you reproduce using one of our samples or online demos?
Are you using the WebViewer server? yes
Does the issue only happen on certain browsers? no
Is your issue related to a front-end framework?
Is your issue related to annotations? yes

Please give a brief summary of your issue:
I have few customized stamp annotations. And i am setting the width and height of the stamps when annotations are added as shown below:
annotationManager.addEventListener(“annotationChanged”, (annotations, action, { imported }) => {
if (!imported && annotations.length == 1) {
const annot = annotations[0];
if (annot instanceof instance.Core.Annotations.StampAnnotation && action === ‘add’) {
annot.Width = 100;
annot.Height = 35;
instance.Core.annotationManager.redrawAnnotation(annot);
}
}
});

The issue is when I rotate a page in pdf file and add the stamp. The height and width are swapped which makes the stamp to look weird.
Annotation added on portrait page: Height(35) and Width(100) are maintained as mentioned

Annotation added on landscape page (Portrait page is rotated clockwise): Height(100) and Width(35) are swapped


todelete.pdf (34.3 KB)

Hi there,

For landscape documents, you should have a condition in that event listener to rotate the annotation.

I.e.

annotationManager.addEventListener('annotationChanged', (annotations, action, { imported }) => {
    const annot = annotations[0];
    annot.Width = 100;
    annot.Height = 35;
    // get document page rotation via documentViewer.getRotation()
    // modify the annotation's rotation 
    annot.Rotation = annot.Rotation - 90 // where 90 is the page's rotation
    instance.Core.annotationManager.redrawAnnotation(annot);
});

best regards,
Kevin Kim

Hi,

I dont want to rotate the annotation in landscape pages.
Is there any way to add annotation as it is in landscape pages without rotating the annotation?
like this

It can be like finding whether the page is portrait or landscape? Based on that we can assign height and width.

Thanks
Priya K

Unfortunately, we don’t have an API to set the rotation of the annotation on creation. The method shared above is a way to rotate the annotation on creation.

If you load a landscape document on the showcase and then proceed to create an annotation (i.e. free-text) you can see that the annotation also has its rotation applied:

Best regards,
Kevin Kim