Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create Custom Tool to rotate odd and even pages differently?

Community Beginner ,
Jul 31, 2025 Jul 31, 2025

I very frequently need to do this routine: choose Organize Pages, select all odd pages, rotate 90º CW, select all even pages, rotate CCW. I'd like to create a Custom Tool to do this but don't see how to select odd/even pages. Any advice?

TOPICS
Edit and convert PDFs , How to
489
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jul 31, 2025 Jul 31, 2025

You can do it by adding this JavaScript code to your Custom Tool:

 

for (var i=0; i<this.numPages; i++) {
	if (i%2==0) this.setPageRotations(i, i, 90);
	else this.setPageRotations(i, i, 270);
}

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2025 Jul 31, 2025

You can do it by adding this JavaScript code to your Custom Tool:

 

for (var i=0; i<this.numPages; i++) {
	if (i%2==0) this.setPageRotations(i, i, 90);
	else this.setPageRotations(i, i, 270);
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 31, 2025 Jul 31, 2025

Thank you. I'm sure I've done something incorrectly; when I click either "Start" or "Execute JavaScript" from the tool I created in Action Wizard with your script I get this dialog box, but when I click OK it reports "Completed" with no change in page orientation.

 

phidler_0-1754009473307.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2025 Aug 01, 2025

Works fine for me...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2025 Aug 01, 2025

Maybe the pages in your file are already rotated (even if they don't look like it). To accommodate for that try this code:

 

for (var i=0; i<this.numPages; i++) {
	var pageRotation = this.getPageRotation(i);
	if (i%2==0) pageRotation+=90;
	else pageRotation-=90;
	
	if (pageRotation==360) pageRotation = 0;
	else if (pageRotation==-90) pageRotation = 270;
	
	this.setPageRotations(i, i, pageRotation);
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 01, 2025 Aug 01, 2025
LATEST

Brilliant! That was exactly it; I was trying the script on a file to which I had already applied page rotations. When testing it with a fresh scan it works exactly as I need. Thanks a million!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines