Jump to content

Pages duplicating


aarion63

Recommended Posts

Hi everybody,

here is my issue :

 

My fusionpro file contains many (5) bodypages wich are all different.

 

i have a database wich contains many datas (like name, mail, tel ...) and 5 fields (wich define quantity for duplicating each pdf page).

 

field 1 (for page 1) : 5 (quantity for duplicating pdf page 1)

field 2 (for page 2) : 3 (quantity for duplicating pdf page 2)

field 3 (for page 3) : 4 (quantity for duplicating pdf page 3)

name : DOE

last name : john

tel : +33789779797

 

 

At the end, the pdf must be composed of all page models with different quantity in fonction of corresponding fields values.

 

Coul someone help me to find the correct javascript rule to make it please ? Because i' am a noob in javascript developpement.

 

I tried a "onrecordstart" rule like "FusionPro.Composition.repeatRecordCount = Field("field 1");" but it seems to duplicate all pages with the same quantity

 

thanks in advance.

Edited by aarion63
Link to comment
Share on other sites

The way to do this currently is like so: Set the repeat count for the record to the total number of repeats for all pages. Then, call FusionPro.Composition.SetBodyPageUsage() with the second parameter set to either true or false for each page, based whether the page number is in the current repeat range.

 

The code would look something like this:

var repeats = [];
for (var i = 1; i <= 5; i++)
   repeats.push(Int(Field("Field " + i)));

var ranges = [];
for (var i in repeats)
   ranges.push(Int(ranges.slice(-1)) + repeats[i]);

FusionPro.Composition.repeatRecordCount = Int(ranges.slice(-1));

var r = FusionPro.Composition.repeatRecordNumber;
for (var p in ranges)
{
   var usage = (r > Int(ranges[int(p)-1])) && (r <= ranges[p]);
   FusionPro.Composition.SetBodyPageUsage(Int(p)+1, usage);
}

Of course, this is actually composing each record multiple times, and throwing out most of the pages from each pass, so it's not terribly efficient. We're considering adding a feature to FusionPro to more easily specify individual page repeats, without having to re-compose multiple times.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...