Skip to main content
Sonny AR
Inspiring
February 27, 2025
Question

Rearrange Pages in Reverse Order

  • February 27, 2025
  • 1 reply
  • 235 views

Hello Experts,

I want to create an Action Wizard to arrange selected pages in reverse order within a document.

For example, if I have a 25-page document and pages 3 to 12 are in reverse order, I’d like to be able to select those 10 pages range through a prompt window, press a button, and have them arranged in the correct order and rest of the pages remain same position.

How can I achieve this?

Thanks in advance

1 reply

PDF Automation Station
Community Expert
Community Expert
February 27, 2025

Here's a simple script to reverse all pages:

for (var i = 0; i < this.numPages; i++) 
{
this.movePage(i, -1);
}

If you want a specified range of pages that isn't all the pages, you would need to change 3 numbers in the script above.  For example, if you wanted to leave the first 2 and the last 2 and reverse the pages in between the script would be modified like this:

for (var i = 2; i < this.numPages-2; i++) 
{
this.movePage(i, 1);
}

Remember that page numbers are zero-based.  Use it an Action to Execute Javascript.  You could also add a popup dialog at the beginning of the Action to specifiy the page range.

https://pdfautomationstation.substack.com/p/how-it-solved-the-acrobat-popup-dialogaction

If you're interested in development of this for a fee, please message me privately by clicking my icon.