0
votes

I tried to read the page orientation from a pdf-document with JavaScript in Adobe Acrobat.

To place a textfield in the right position, I use the getpagerotation() function to get the orientation of the document.

var rotation = this.getpagerotation(p);

(p is a variable with the number of each page)

I tried this code with landscape and portrait orientation.

But the function always gives the 0 as the value of rotation which is wrong because the value of portrait rotation should be 90 instead of 0.

What is wrong with the function?

1
You can get both landscape and portrait pages with arbitrary page rotations.mkl
What happens when you manually change the rotation of a page (note, not the view in the PDF viewer, but using the according command). Note that it is possible to have portrait and landscape pages, both having the same rotation.Max Wyss
If arbitrary page rotations means or leads to the getPageBox this is right, thanks.highfive-2017

1 Answers

0
votes

thanks to the adobe community I got an solution for my anwser.

I have to use the getPageBox method. You have to calculate the width or height of the document to get the orientation.

     var aRect = this.getPageBox("Media");
     var width = aRect[2] - aRect[0];
     var height = aRect[1] - aRect[3];

width over 800 is landscape.

Thanks for trying to solve the problem.

highfive-2017