aarion63 Posted December 19, 2014 Share Posted December 19, 2014 (edited) 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 December 19, 2014 by aarion63 Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 19, 2014 Share Posted December 19, 2014 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. Quote Link to comment Share on other sites More sharing options...
aarion63 Posted December 24, 2014 Author Share Posted December 24, 2014 Thanks a lot Dan. As always, you're the best I'll try this one. 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.