Skip to main content
undZack
Participant
August 10, 2021
Answered

This.getpagerotation gibt nur den Wert 0 zurück

  • August 10, 2021
  • 3 replies
  • 687 views

Hallo,

 

für die richtige Positionierung eines Textfeldes benötige ich die Orientierung der Seite.

ich nutze dafür 

 

var rotation = this.getpagerotation(1);

 

leider bekomme ich egal, ob Hoch- oder Querformat immer den Wert 0 für die Variable rotation.

Für die Seitennummerierung nutze ich eine For-Schleife.

Woran kann das liegen?

 

Gruss D.

 

This topic has been closed for replies.
Correct answer Test Screen Name

getPageRotation does not give you a value that can be used to tell the difference between landscape and portrait. That is not what it is for. It is a rotation to be applied to the page boxes, which may already be portrait or landscape. 

 

In outline, to match the user's view of "landscape" or "portrait"

1. Get the page crop box

2. Obtain width and height

3. If the page rotation is 90 or 270 swap the width and height

4. Now use the width and height to decide if portrait or landscape

3 replies

Test Screen NameCorrect answer
Legend
August 10, 2021

getPageRotation does not give you a value that can be used to tell the difference between landscape and portrait. That is not what it is for. It is a rotation to be applied to the page boxes, which may already be portrait or landscape. 

 

In outline, to match the user's view of "landscape" or "portrait"

1. Get the page crop box

2. Obtain width and height

3. If the page rotation is 90 or 270 swap the width and height

4. Now use the width and height to decide if portrait or landscape

Legend
August 10, 2021

Snap!

try67
Community Expert
Community Expert
August 10, 2021

I assume you already used the correct spelling of the method, as Nesa pointed out, otherwise you would have gotten an error message when you ran your code, instead of getting a result of 0.

 

The reason it's returning 0 is because the page is not rotated. Rotation and Orientation are two different things.

You can create a page to have landscape orientation or portrait orientation, and neither will be rotated.

Or you can create a page in landscape orientation and then rotate it to become portrait, or vice versa.

Only in the latter scenario will getPageRotation return a value of 90 or 270.

So in addition to checking the rotation of the page you also need to check its actual width and height, which you can do using the getPageBox method. I recommend you read the documentation of the latter, as each page has multiple such boxes, and they don't all have to be the same...

undZack
undZackAuthor
Participant
August 11, 2021

Thank you for the anwser.

 

I did think about it to.
Maybe if there is another way of finding  the side-orientation.

Like PageBox.

 

undZack

Nesa Nurani
Community Expert
Community Expert
August 10, 2021

Use this.getPageRotation not this.getpagerotation.

undZack
undZackAuthor
Participant
August 11, 2021

Hallo Nesa,

 

thank you for your anwser, the spelling I use is right. I use MS Visual Code. 

undZack