Kal Posted August 17, 2016 Share Posted August 17, 2016 Is there a way to pull random static pages. I have a layout with 50 pages and pages named 1 to 50 in the "Page Usage" Everyone gets Page1 & 2 then it's random and everyone gets the last 2 pages 49 & 50. Static Pages 3 to 48 can be in any order like P3, 4, 5 or P4, 3, 47, 11, 5 I can have a data file created and populated with the pages that need to be pulled. Field called "VarPages" How do I do this in "OnRecordStart" Hope this is clear enough. Quote Link to comment Share on other sites More sharing options...
step Posted August 17, 2016 Share Posted August 17, 2016 You can't re-order pages in your template from OnRecordStart – you can only turn them on/off. Is that a requirement? If so, I would suggest having a 5 page template with pages 1, 2, 4, and 5 as static pages that always return pages 1, 2, 49 and 50 (respectively) and the 3rd page being an overflow page that adds a random number of pages, each pulling a different random page from the other 46 pages: var pdf = CreateResource('path/to/your.pdf', 'graphic'); var pages = []; for (var i=2; i<49; i++) pages.push(i); return pages .sort(function(){ return .5 - Math.random(); }) .splice(0, Math.floor((Math.random() * pages.length) + 1)) .map(function(s){ pdf.pagenumber = s; return pdf.content; }) .join('<p>'); If you don't mind if they stay in order, you can variably turn random pages on and off like this: for (var i=2; i<49; i++) if (Math.round(Math.random())) FusionPro.Composition.SetBodyPageUsage(i, true); Quote Link to comment Share on other sites More sharing options...
Kal Posted August 18, 2016 Author Share Posted August 18, 2016 Thanks Ste, I'll give that a try. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.