Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It works now. Thanks for your support.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now