When a page is actually rotated, we can getPageRotation() from the document object for each page: But if the view is rotated with the buttons on the bottom of the screen, I can't find any function or property that lists that rotation, or provides a reliable clue about it. I saw in the adobe documentation they have an undocumented function Matrix2D.fromRotated() that tries to figure it out from Media and Crop box coordinates, but in my testing it's unreliable.
Isn't the view rotation a property of the document similar to .zoom? Is there such a property, or if not, can Tracker add one? Without this, it's impossible to know where "left" or "top" is from javascript.
javascript: Is there a way to get the view rotation?
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan, Ivan - Tracker Software
- Tracker Supp-Stefan
- Site Admin
- Posts: 16183
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: javascript: Is there a way to get the view rotation?
Hello Mathew,
What are you trying to make this JS do?
The 'view rotation' is just a visual appearance change, and does not really affect the contents of the pages, so if you need to e.g. move content from one page to another - the view rotation would have affected them all and not have an effect on another operation.
There are methods in the no longer available for sale Editor SDK that can get and set the view rotation - but those are UI settings, and not really ones that you can access from inside the PDF file with JS.
Kind regards,
Stefan
What are you trying to make this JS do?
The 'view rotation' is just a visual appearance change, and does not really affect the contents of the pages, so if you need to e.g. move content from one page to another - the view rotation would have affected them all and not have an effect on another operation.
There are methods in the no longer available for sale Editor SDK that can get and set the view rotation - but those are UI settings, and not really ones that you can access from inside the PDF file with JS.
Kind regards,
Stefan
Re: javascript: Is there a way to get the view rotation?
Hi Stefan,
My case is simply that I want to be able to have a dialog box for a script that mirrors markup, and be able to say "mirror horizontally". If I don't know the view rotation as well as the page rotation, I cannot know what is "horizontal" within the script.
Actually PDF x-change also has problems with this with the "transform" and "duplicate" tools, as well as with "resize pages..." tool. (ie If the view is rotated 90 degrees left, the horizontal offset in Duplicate is actually down).
My case is simply that I want to be able to have a dialog box for a script that mirrors markup, and be able to say "mirror horizontally". If I don't know the view rotation as well as the page rotation, I cannot know what is "horizontal" within the script.
Actually PDF x-change also has problems with this with the "transform" and "duplicate" tools, as well as with "resize pages..." tool. (ie If the view is rotated 90 degrees left, the horizontal offset in Duplicate is actually down).
- TrackerSupp-Daniel
- Site Admin
- Posts: 6978
- Joined: Wed Jan 03, 2018 6:52 pm
Re: javascript: Is there a way to get the view rotation?
Hello, Mathew
I see, for clarity sake there are two different ways to rotate pages.
~"Rotate View" is, as stefan mentioned not something which has any effect on the document or commands applied to it. This means that if you have the "view" rotated 90 degrees, using a "Flip horzontal" command will cause the object to flip horzontally based on the documents original orientation (IE it will move veritcally from your current perspective). There is no way to detect that through JS that I am aware of, since it happens outside the document context, and is not something defined via the PDF specification (as it does not actually affect or ever get embedded into the PDF file).
~"Rotate page" is the option which will directly modify the content of the document, it will change the "rotation" property of the pages, and will cause features like the "flip horizontal" to work differently. In this case, if you us the "flip horizontal on a comment before or after using the "rotate page" command, the object will always be flipped horizontally from your perspective.
I hope this helps to explain the differences between these two functions and their uses.
Kind regards,
I see, for clarity sake there are two different ways to rotate pages.
~"Rotate View" is, as stefan mentioned not something which has any effect on the document or commands applied to it. This means that if you have the "view" rotated 90 degrees, using a "Flip horzontal" command will cause the object to flip horzontally based on the documents original orientation (IE it will move veritcally from your current perspective). There is no way to detect that through JS that I am aware of, since it happens outside the document context, and is not something defined via the PDF specification (as it does not actually affect or ever get embedded into the PDF file).
~"Rotate page" is the option which will directly modify the content of the document, it will change the "rotation" property of the pages, and will cause features like the "flip horizontal" to work differently. In this case, if you us the "flip horizontal on a comment before or after using the "rotate page" command, the object will always be flipped horizontally from your perspective.
I hope this helps to explain the differences between these two functions and their uses.
Kind regards,
Daniel McIntyre - Support Technician
Tracker Software Products (Canada) LTD
Support: <Support@tracker-software.com>
Tracker Software Products (Canada) LTD
Support: <Support@tracker-software.com>
Re: javascript: Is there a way to get the view rotation?
Daniel,
The doc object has a .zoom property that reports the current view zoom. Is that saved with the document? Can Tracker add a .pageViewRotation (for example) property to the .viewState object, even though it's not documented in the adobe api reference?
I guess what I'm getting at is: Is PDF-xchange bound to some standard that prevents you from adding a property that would make a lot of tools be a lot more user-friendly?
The doc object has a .zoom property that reports the current view zoom. Is that saved with the document? Can Tracker add a .pageViewRotation (for example) property to the .viewState object, even though it's not documented in the adobe api reference?
I guess what I'm getting at is: Is PDF-xchange bound to some standard that prevents you from adding a property that would make a lot of tools be a lot more user-friendly?
- Ivan - Tracker Software
- Site Admin
- Posts: 3529
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: javascript: Is there a way to get the view rotation?
added viewState.pageViewRotation in the next major build.
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
- Paul - Tracker Supp
- Site Admin
- Posts: 6462
- Joined: Wed Mar 25, 2009 10:37 pm
- Location: Chemainus, Canada
- Contact:
javascript: Is there a way to get the view rotation?

Best regards
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com