These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Randomly displays pages

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766

Hi,
 
I know that JavaScript can be used to navigate through pages (go 1st, go last, go previous, go next, go to n).
But I don't know if JavaScript can display the next page randomly.
 
ie: 1000 JPGs pictures combined into one PDF displayed as a slide show (full-screen mode), but I would pages to be displayed randomly, not using the page order.
 
Is it possible, and how ?
 
Thanks

My Product Information:
Acrobat Pro 9.3.1, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2398
This code will cause the file to switch to a random page between 0 and 999 (pages are 0-based in a script):

this.pageNum = Math.floor(Math.random()*1000);

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
Thanks, this helps me a lot and I'd enhanced your sample as this :

var nbP = this.numPages;
this.pageNum = Math.floor(Math.random()*nbP);

(Then I didn't have to previously known the number of pages…)


This is good stuff for a button action, but I want the slide show to be opened automaticaly (this is OK) and the pages/images to be displayed randomly without any user action.

I guess that I must use a doc-level JavaScript, but how can I repeat this script any "n" second ???
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
I get this script from the JS-doc, I modified it, and it works!
Thanks again try67.
;-)


function DoIt() {
var nbP = this.numPages;
this.pageNum = Math.floor(Math.random() * nbP);
}

//save return value as a variable
timeout = app.setInterval("DoIt()", 11000);
// Add a property to our timeout object so that DoIt() can keep a count going.
timeout.count = 0;


/* use this as a doc-will-close JavaScript */
if (typeof app.formsVersion != 'undefined' && app.formsVersion < 7.05)
{app.clearInterval(timeout)};