Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 17th, 2016, 02:27 PM
Kal's Avatar
Kal Kal is offline
Regular Contributor
 
Join Date: Jun 2011
Location: Canada
Posts: 56
Default Random pulls of static pages

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.
__________________
Kal Bedi
FusionPro Desktop 10.1.9
Adobe Acrobat Pro DC
Mac OS Sierra 10.12.5
Canada
Reply With Quote
  #2  
Old August 17th, 2016, 04:01 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Random pulls of static pages

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:
Code:
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:
Code:
for (var i=2; i<49; i++)
  if (Math.round(Math.random())) 
    FusionPro.Composition.SetBodyPageUsage(i, true);
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old August 18th, 2016, 09:00 AM
Kal's Avatar
Kal Kal is offline
Regular Contributor
 
Join Date: Jun 2011
Location: Canada
Posts: 56
Default Re: Random pulls of static pages

Thanks Ste, I'll give that a try.
__________________
Kal Bedi
FusionPro Desktop 10.1.9
Adobe Acrobat Pro DC
Mac OS Sierra 10.12.5
Canada
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:02 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.