Moving PDF Pages With Adobe Acrobat
Use 'drag and drop' or follow along with three scripting exercises
There is no Acrobat user interface functionality for moving pages. However, pages can easily be dragged and dropped to different positions within the pages panel. The JavaScript document method, movePage( ) is fairly simple and only takes two parameters, but it can be tricky to work with. Since it only moves one page, creativity must be used to move multiple pages by repeating the script. When this type of script is written the programmer must remember to envision the new page order from the previous script before the repetition or it will produce unintended results that can be difficult to troubleshoot.
DRAG AND DROP
1) Open the pages panel.
2) Select a page, or set of pages.
3) Drag the selected pages to a new position in the pages panel.
JAVASCRIPT
The movePage( ) method does not access the file system so it does not need to be run from a privileged context. Both input parameters are optional:
1) nPage – The page number of the page to move. If not specified, the default is 0 (the first page of the document).
2) nAfter – The page number after which to move the nPage. If not specified, the default is the last page of the document.
THREE PRACTICAL EXERCISES
I have created three practical exercises that you can follow along with to understand how to use the movePage( ) method. Simply download the PDF and follow along:
EXERCISE 1
1)Â Â Open the file Moving_Pages_Test1 and open the pages panel.
2)Â Â Run the following script in the console:Â this.movePage();
3)  Since no parameters were specified, both defaults were used. nPage is 0 (the first page) and the nAfter is 6 (page 7, the last page of the document). Check to make sure the page marked Page 1 is now the last page of the document.
4)  Run the script again. The markings on the pages should now be, in order, Page 3, Page 4, Page 5, Page 6, Page 7, Page 1, Page 2.
5)Â Â Close the file without saving.
EXERCISE 2
In this exercise, we are going to create a script to reverse the order of all pages in a document. This script will be able to be applied to any PDF with any number of pages (as long as the PDF security does not prevent "changing the document"). There are two ways to accomplish this:
A.   A loop that moves the first page to the beginning of the document, then moves each subsequent page to the beginning.
A.   A reverse loop that moves the last page of the document to the end of the document, and each preceding page to the end of the document.
Here is the loop script from point A above:
for (var i = 0; i < this.numPages; i++)
{
this.movePage(i, -1);
}
var i is defined as 0 (the first page in the document). As long as i is less than the number of pages in the document, i will increment by 1 and then the script will run. For the 7-page document we are going to use, the nPage parameter will be 0, 1, 2, 3, 4, 5, 6 when the loop runs.  The nAfter parameter will be -1, which means pages 1 through 7 will be moved to the beginning of the document.
Here is the reverse loop script from point B above:
for (var i = this.numPages - 1; i >= 0; i--)
{
this.movePage(i);
}
var i is defined as the last page of the document (number of pages minus 1, to get the zero-based page index). As long as i is greater than or equal to zero, i will decrement by 1 and the script will run. For the 7-page document we are going to use, the nPage parameter is 6, 5, 4, 3, 2, 1, 0 when the loop runs. The nAfter page does not need to be specified because the default is the last page of the document, so pages 7 through 1 will be moved to the end of the document, resulting in the same outcome as script A (the pages will be reversed.
1)Â Â Open the document Moving_Pages_Test1 and open the pages panel.
2)  Copy the script from point A above, paste it into the console, then run the script. Remember that the entire script must be selected in the console because it spans multiple lines.
3)  Examine the pages. They should be reversed (Page 7, Page 6, Page 5…Page 1).
4)Â Â Copy the script from point B above, paste it into the console, then run it.
5)  Examine the pages.  They should be reversed, putting them back in the original order (Page 1, Page 2, Page 3…Page 7).
6)Â Â Close the file without saving.
For more practical lessons to learn JavaScript for Acrobat Pro, check out our online course.
EXERCISE 3
1)Â Â Open the document Moving_Pages_Test1 and open the pages panel.
2)Â Â Copy script A above to the clipboard.
3)Â Â Â Enter field editing mode by pressing Ctrl + Shift + 7.
4)Â Â Â Right click the blue button in the upper left corner of page 1 and select Properties.
5)   In the Actions tab, select the Mouse Up trigger and the Run a JavaScript action, then  click Add.
1)Â Â Paste the script from step 2 into the window.
2)Â Â Â Close the window by clicking the x.
3)Â Â Â Click the Save button.
4)Â Â Â Click the Close button.
5)Â Â Â Copy the script from point B above.
6)Â Â Â Go to page 7 and repeat steps 3 through 9 for the blue button on page 7.
7)Â Â Â Exit form editing mode by pressing Ctrl + Shift + 7.
8)   Click the blue button. Every time you click one of the blue buttons, either on page 1 or page 7, the pages should reverse.
NOTE: While we just created buttons that reverse the order of the pages in Acrobat Pro, these buttons would only be useful if you were confident that only Acrobat Pro users would use the document. It would not be suitable for broad based use where many users would access the document with Adobe Reader. These buttons will not function with Adobe Reader because it does not support the movePage() method. Just because you can manipulate a document in this way with a script, does not mean you can add functionality to software that does not exist. You should always check Reader functionality when creating forms or documents for broad base use.