David Weisman Posted October 28, 2013 Share Posted October 28, 2013 Is there some javascript that will allow me to repeat a record x number of times (like 50, 100 or 200). That value can be either in a field or fixed in the java script. What we are doing is printing half a dozen business cards on a sheet, but we need to have 100 copies of some cards, and 50 of another. Thanks, David Quote Link to comment Share on other sites More sharing options...
FreightTrain Posted October 28, 2013 Share Posted October 28, 2013 Check this thread: http://forums.printable.com/showthread.php?t=2906&highlight=repeat+record Quote Link to comment Share on other sites More sharing options...
David Weisman Posted October 28, 2013 Author Share Posted October 28, 2013 Thanks for the great resource. I'm testing it out now. David Quote Link to comment Share on other sites More sharing options...
David Weisman Posted October 30, 2013 Author Share Posted October 30, 2013 I've now been given a more complicated version of this. I need to output a file in which the first page is a job ticket and has information about the job, the following pages repeat the job, say 50 times. Then this is followed by the job ticket again. Can this be done? Quote Link to comment Share on other sites More sharing options...
esmith Posted October 30, 2013 Share Posted October 30, 2013 fp_example.pdf contains 3 pages -- a job ticket and 2 "body" pages. The output.pdf shows the result (I think) you are trying to achieve. You should be able to compose the former file as is (currently uses Futura Bold) to reproduce the output. The OnRecordStart callback rule set each record to repeat 50 times and disables the job ticket on the 2nd thru 50th iterations while adding a 51st record which adds the job ticket only. The OnJobStart rule is only used in the example to bypass a data file for demonstration purposes.fp_example.pdfoutput.pdf Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 30, 2013 Share Posted October 30, 2013 I need to output a file in which the first page is a job ticket and has information about the job, the following pages repeat the job, say 50 times. That's pretty easy; just do this in your OnRecordStart rule: FusionPro.Composition.repeatRecordCount = 50; // FusionPro.Composition.repeatRecordCount = Int(Field("repeat")); // or this FusionPro.Composition.SetBodyPageUsage(1, FusionPro.Composition.repeatRecordNumber == 1);Then this is followed by the job ticket again. Can this be done? That's a bit more complicated. One way to do this is to add an extra record at the end of the job, then suppress all the other pages except the first one; something like this: FusionPro.Composition.repeatRecordCount = 51; // adding one here // FusionPro.Composition.repeatRecordCount = Int(Field("repeat")) + 1; // or this FusionPro.Composition.SetBodyPageUsage(1, FusionPro.Composition.repeatRecordNumber == 1); if (FusionPro.Composition.repeatRecordNumber == FusionPro.Composition.repeatRecordCount) { // Last record; output just the first page. FusionPro.Composition.SetBodyPageUsage(1, true); for (var p = 2; p < 100; p++) { try { // this throws an error if the name number is invalid FusionPro.Composition.SetBodyPageUsage(p, false); } catch (e) { // no more pages to set usage for break; } } } Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 30, 2013 Share Posted October 30, 2013 I see Eric beat me to the punch. His solution is perfectly fine. Although mine takes advantage of the fact that, as long you're in FusionPro 8.0 or newer, you don't actually need to name the pages; you can just use page numbers in the calls to FusionPro.Composition.SetBodyPageUsage(). So mine is more generic, since it should work for any job, regardless of the number of pages or their names (or lack of names). Quote Link to comment Share on other sites More sharing options...
David Weisman Posted October 30, 2013 Author Share Posted October 30, 2013 Thanks, guys I actually was just coming back to say that I did something that worked (and shocked myself!). FusionPro.Composition.SetBodyPageUsage("Ticket" , false); if (FieldChanged("Column")) { FusionPro.Composition.SetBodyPageUsage("Ticket" , true); } FusionPro.Composition.repeatRecordCount = Int(Field("Qty")); Quote Link to comment Share on other sites More sharing options...
David Weisman Posted October 30, 2013 Author Share Posted October 30, 2013 The final question is imposition - and I've tried various stacking, horizontal and vertical combinations. I need 5 different tickets to be placed in a vertical row, with the pdfs following horizontally in as many sheets it takes to print 50 of each of 5 pdfs. Quote Link to comment Share on other sites More sharing options...
step Posted October 30, 2013 Share Posted October 30, 2013 I'm having a hard time visualizing what it is you're trying to accomplish with the imposition. How many business cards are you trying to get up on a sheet? 20? 5 rows and 4 columns? If that's the case, I'd think you'd just set your stack height to be pieces/columns (i.e 51/4=13. 51 because of the ticket at the start of the set of 50) in the imposition definition. It might help if you could post an example of how you'd like the output to look. But you should consider that when you impose the job, you need to make sure that each record produces the same number of pages. By that I mean, when you turn on the ticket page, you need to turn off the business card page. I'd modify your code to look like this: FusionPro.Composition.repeatRecordCount = Int(Field("Qty")) + 1; // add one for the ticket FusionPro.Composition.SetBodyPageUsage("Ticket" , FusionPro.Composition.repeatRecordNumber == 1); FusionPro.Composition.SetBodyPageUsage(2, FusionPro.Composition.repeatRecordNumber != 1); Quote Link to comment Share on other sites More sharing options...
David Weisman Posted October 31, 2013 Author Share Posted October 31, 2013 Thanks Ste, I was aiming for 5 rows and 5 columns, and the latest code did the trick David Quote Link to comment Share on other sites More sharing options...
David Weisman Posted November 2, 2013 Author Share Posted November 2, 2013 Well, I have spent quite a few hours today trying to do this myself. You can tell me I've reached my limit on free meals (though I used FP for 6 years in another job and never asked a question) For each record, I want to output a beginning ticket, x copies of the job, and an end ticket. The following code gives me the right count, but it places the two tickets at the beginning and then the repeated page. In Page Usage they are also in the order that I want to output. FusionPro.Composition.repeatRecordCount = Int(Field("Qty")) + 2; FusionPro.Composition.SetBodyPageUsage("Ticket", FusionPro.Composition.repeatRecordNumber == 1); FusionPro.Composition.SetBodyPageUsage("PDF", FusionPro.Composition.repeatRecordNumber != 1); FusionPro.Composition.SetBodyPageUsage("Ticket2", FusionPro.Composition.repeatRecordNumber == 1); Quote Link to comment Share on other sites More sharing options...
esmith Posted November 4, 2013 Share Posted November 4, 2013 (edited) For each record, I want to output a beginning ticket, x copies of the job, and an end ticket. The following code gives me the right count, but it places the two tickets at the beginning and then the repeated page. In Page Usage they are also in the order that I want to output. repeatRecordCount tells FP how many times to run each record. repeatRecordNumber tells FP which iteration of the repetition of the current record it is on. setBodyPageUsage takes two arguments: the page name (or number) and true/false (whether to activate page or not). In Ste's code, the 2nd argument is an equation that yields either true or false so in your modification: FusionPro.Composition.SetBodyPageUsage("Ticket", FusionPro.Composition.repeatRecordNumber == 1); activates "Ticket" on the first iteration (repeatRecordNumber is equal to 1), FusionPro.Composition.SetBodyPageUsage("PDF", FusionPro.Composition.repeatRecordNumber != 1); activates "PDF" for everything BUT the first iteration (repeatRecordNumber is not equal to 1), and FusionPro.Composition.SetBodyPageUsage("Ticket2", FusionPro.Composition.repeatRecordNumber == 1); activates "Ticket2" for the first iteration (repeatRecordNumber is equal to 1). Make sense? In order to generate each record with 1 "Ticket" followed by X "PDFs" followed by 1 "Ticket2", you would need your second arguments to yield: repeatRecordNumber equals 1repeatRecordNumber greater than 1 AND less than X+2 (repeatRecordCount)repeatRecordNumber equals X=2 (repeatRecordCount) Are you still with me? To do this, I would revise your code like this: var finalTicket = Int(Field("Qty")) + 2; FusionPro.Composition.repeatRecordCount = finalTicket; FusionPro.Composition.SetBodyPageUsage("Ticket", FusionPro.Composition.repeatRecordNumber == 1); FusionPro.Composition.SetBodyPageUsage("PDF", FusionPro.Composition.repeatRecordNumber > 1 && FusionPro.Composition.repeatRecordNumber < finalTicket); FusionPro.Composition.SetBodyPageUsage("Ticket2", FusionPro.Composition.repeatRecordNumber == finalTicket); I opted to assign "X+2" to a variable so that the following code would be a bit cleaner. The double ampersands means "AND" which means both equations must test true to activate page. Now that you understand what the code is doing, you may not need that free meal (but if you do, there are always others willing to help). Edited November 4, 2013 by esmith Quote Link to comment Share on other sites More sharing options...
David Weisman Posted November 5, 2013 Author Share Posted November 5, 2013 Eric, Thank you very much. I particularly appreciate that you have defined the FusionPro.Composition functions; I have been searching for that information for a while. BTW - I spent a week down there about 7 years ago when we were getting trained in Fusion Pro web. Funny thing, we didn't get a free lunch then, we went (usually) to the little grocery on the corner. David 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.