Annotations create programmatically without rotation

PDF.js Express Version
7.3.0

Detailed description of issue
When I create an annotation programmatically it inherits the rotation of the document, when creating an annotation through the UI it appears right side up which is what I would like.

Expected behaviour
Create the annotation so the top is the top and not rotated with the document

Does your issue happen with every document, or just one?
All

Code snippet
Here is how I am creating the annotation

     async function AddButton(text, id, text_colour, fill_colour, width, height, x, y, font_size, page_num) {
            const centerPageCoordinates = getCenter();
            const freeText = new Annotations.FreeTextAnnotation();
            if (page_num == -1) {
                page_num = docViewer.getCurrentPage();
                x = centerPageCoordinates.x - (width / 2);
                y = centerPageCoordinates.y - (height / 2);
            }

            freeText.PageNumber = page_num;
                freeText.X = x;
                freeText.Y = y;
                freeText.Width = width;
                freeText.Height = height;
                freeText.setPadding(new Annotations.Rect(0, 0, 0, 0));
                freeText.setContents(text);
                freeText.TextColor = new Annotations.Color(text_colour);
                freeText.FillColor = new Annotations.Color(fill_colour);
                freeText.TextAlign = 'center';


                freeText.FontSize = font_size;
                freeText.NoRotate = true;
                freeText.NoResize = true;
                freeText.MaintainAspectRatio = true;
                freeText.ToolName = '{{' + id + '}}';
                freeText.LockedContents = true;

            annotManager.deselectAnnotations(annotManager.getAnnotationsList());
                annotManager.addAnnotation(freeText);
            annotManager.redrawAnnotation(freeText);
            //annotManager.bringToFront(freeText);


        }

VideoExample

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Eric!

(Sorry for the wait on this, been a crazy week).

My answer here should help resolve your issue. Basically you just need to check the rotation of the page (you can use this api) and set the annotation rotation accordingly.

Let me know if you have any other issues.

Thanks!
Logan