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

How to shuffle PDF pages randomly

New Here ,
Aug 07, 2025 Aug 07, 2025

Hello,

I have a multipage PDF with about 500 pages. The pages contain variable content, so each page looks slight different. I am looking for a way to shuffle the page or in other words to automatically and randomly mix pages in the page position. So that i.e page one becomes page 300 and page 488 becomes page 2 and so forth. I do not want to do a manual page move.

Any idea?

TOPICS
Al Assistant , Edit and convert PDFs , PDF , Print and prepress
351
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 ,
Aug 07, 2025 Aug 07, 2025

You can do it by executing this JavaScript code, for example from a Custom Command. Edit the value in the first line to change the number of "shuffles" that will take place. Even with a low number you will get pretty good results, as both the source page and the target page are random.

 

var numShuffles = 500;
for (var i=0; i<=numShuffles; i++) {
	var sourcePage = Math.floor(Math.random()*this.numPages);
	var targetPage = Math.floor(Math.random()*this.numPages);
	this.movePage(sourcePage, targetPage);
}

 

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 ,
Aug 07, 2025 Aug 07, 2025

You can do it by executing this JavaScript code, for example from a Custom Command. Edit the value in the first line to change the number of "shuffles" that will take place. Even with a low number you will get pretty good results, as both the source page and the target page are random.

 

var numShuffles = 500;
for (var i=0; i<=numShuffles; i++) {
	var sourcePage = Math.floor(Math.random()*this.numPages);
	var targetPage = Math.floor(Math.random()*this.numPages);
	this.movePage(sourcePage, targetPage);
}

 

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
New Here ,
Aug 07, 2025 Aug 07, 2025

That code shows a syntax error when using Javascript in Acrobat Pro on an open multipage PDF. Can you guide me on how to use your code on a PDF. I'm not a programmer unfortunatelly.

 

Thanks

Mike

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 07, 2025 Aug 07, 2025

There's no syntax error. Either you edited it incorrectly or you're not running the full code. You don't need to be a programmer. Just run it as-is from a Custom Command or the JS Console. If you're doing the latter make sure to select all of it before executing it.

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
New Here ,
Aug 07, 2025 Aug 07, 2025
LATEST

It works now. Thanks for your support. 

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