Jump to content

onRecordStart Imposer combo


tou

Recommended Posts

FushionPro VDP Creator 9.3.21

 

I'm trying to create pads with a cover sheet for every 1st record out of 25 records....so

 

record 1 would utilize the following: cover, pad page

record 2 would utilize the following: pad page

....

....

record 25 would utilize the following: pad page

 

record 26 would utilize the following: cover, pad page

record 27 would utilize the following: pad page

....

....

record 28 would utilize the following: pad page

 

and so on pattern wise.

 

my problem is that when I compose it with out FusionPro Imposer I get a nice 1-up document that looks ok, but if I multi-up the document using FusionPro Imposer, I'm getting blank pages.

 

I see that my log file says the following also:

Composing record #1, input record 1

Sheet #1, record #1

Composing record #2, input record 26

Sheet #1, record #2

Composing record #3, input record 2

Sheet #3, record #1

The number of pages in this record does not match the imposition signature: 1 blank pages will be added.

Composing record #4, input record 27

Sheet #3, record #2

1 blank pages will be added.

.....and so on

 

 

Attached are the 1-up and 2-up documents.

 

I've set my first page as unused and in my onRecordStart I have the following code:

 

var a = FusionPro.Composition.inputRecordNumber;

 

if (FusionPro.Composition.inputRecordNumber % 25 == 1) {

FusionPro.Composition.SetBodyPageUsage('Body_1', true)

}

 

Thank in advance!

Output.pdf

Output - 2up.pdf

Link to comment
Share on other sites

Your imposition signature is set to two pages per record. Therefore you need to output two pages for every record. If you output only one page in a record, FusionPro will add a blank page to fill the signature.

 

If you want a slip sheet, set that on the Imposition tab of the Composition Settings. You can set it to be output at the start of every stack, or after a set number of imposed sheets.

Link to comment
Share on other sites

One thing you could do is to have a 1 page per record imposition and repeat the first record every 25 records – so record 1 uses the 'cover' page on its first repeat and uses the 'pad' page on its second repeat:

if (cover = FusionPro.Composition.inputRecordNumber % 25 == 1)
   FusionPro.Composition.repeatRecordCount = 2;

var page = (cover && FusionPro.Composition.repeatRecordNumber == 1) ? 'cover' : 'pad';

FusionPro.Composition.SetBodyPageUsage(page,true);

Link to comment
Share on other sites

Oh, I see.

 

My problem is that they are serialized individual sheets of 25 sheets per pad.

 

I will figure something out, maybe traversing data or something like so.

 

I thought that composed 1 ups results will then get Imposed, so setting the stacks to 26 in this case (or steps of 26) would yield the same results.

 

Thanks for the tips. Its tough when you're Printnet spoiled and try complex programming via scripting.

Link to comment
Share on other sites

My problem is that they are serialized individual sheets of 25 sheets per pad.

 

Okay? I'm not sure how that's a problem. You can still do what I suggested and have your "pad" page return a serialized number (like the record number).

Link to comment
Share on other sites

ok, I will try it out.

 

Just to clarify, I have a data table of 400,000 with serialized data and need the following.

 

1 cover page every 25 records. then they get imposed 4 up onto 13x19 sheet size for digital printing.

 

thanks for your suggestion.

Link to comment
Share on other sites

  • 6 months later...

How would this be written for a duplex job? How would you incorporate a back page for the cover sheet and have the each of the pages compose with a front and back page?

 

Do the cover and the pages share a common back? If so, you wouldn't have to change anything in the code – you'd just set your pages up like this:

  • pg1 'cover' (unused)
  • pg2 'pad' (unused)
  • pg3 'back'

Note that the 'back' page (page 3) is not set to unused in that example. That's because regardless of which page is active for the record, we want page 3 to print as the back for every record.

 

What's more likely, though, is that you have unique backs for the 'cover' page and the 'pad' page. The easiest thing to do in that scenario is to set your back pages up in a similar manner to how the front pages are set up:

  • pg1 'cover' (unused)
  • pg2 'cover-back' (unused)
  • pg3 'pad' (unused)
  • pg4 'pad-back' (unused)

Here we've set all of the pages to unused but all we have to determine is whether or not we're going to use the 'pad' version or the 'cover' version. Since that's essentially what the original code is doing, only the following addition would have to be made (in red):

if (cover = FusionPro.Composition.inputRecordNumber % 25 == 1)
   FusionPro.Composition.repeatRecordCount = 2;

var page = (cover && FusionPro.Composition.repeatRecordNumber == 1) ? 'cover' : 'pad';

FusionPro.Composition.SetBodyPageUsage(page,true);
[color="Red"]FusionPro.Composition.SetBodyPageUsage(page + '-back', true);[/color]

Link to comment
Share on other sites

Thanks so much for the quick reply! That worked perfectly!!

 

I'm adding a sequence code to this as well - and i have the cover sheet setup to add a range rule of:

 

return FusionPro.Composition.inputRecordNumber + " to " + (50 + FusionPro.Composition.inputRecordNumber);

 

I am actually needing to start this numbering with the number 0010001 (including the leading zeros as well). I've tried several scenarios, but cannot seem to get this to function correctly.

 

Suggestions??

Link to comment
Share on other sites

Thanks so much for the quick reply! That worked perfectly!!

No problem! Glad that worked for you

 

I'm adding a sequence code to this as well - and i have the cover sheet setup to add a range rule of:

return FusionPro.Composition.inputRecordNumber + " to " + (50 + FusionPro.Composition.inputRecordNumber);

I am actually needing to start this numbering with the number 0010001 (including the leading zeros as well). I've tried several scenarios, but cannot seem to get this to function correctly.

Suggestions??

 

Well, the code you wrote gives you a range from the current input record number to 50 records from the current input record number – so that part is exactly right. If you don't want to start the sequence at 1, add 10,000 to your starting place:

var start = FusionPro.Composition.inputRecordNumber[color="Red"] + 10000[/color];
var end = start + 50;
return start + ' to ' + end;

 

If you need to pad the number to 7 digits, you can do that with the "FormatNumber" function:

var start = FusionPro.Composition.inputRecordNumber + 10000;
var end = start + 50;
return FormatNumber('0000000', start) + ' to ' + FormatNumber('0000000', end);

 

Or if you're in to one-liners for the sake of being one-liners:

return [0,0].map(function(s,p){ return FormatNumber('0000000', FusionPro.Composition.inputRecordNumber + 10000 + p * 50)}).join(' to ');

Link to comment
Share on other sites

Thanks Ste!

 

I have uploaded the files I'm working with. Would you be able to check to see where I am going wrong?

 

I have the numbering working on the cover page as needed - which show exactly the numbering I need to have in the stack of 50 sheets in the pad. I don't, however, end up with the result of the sheets in the pad numbering to match the cover sheet.

 

My composed file named 147316_Final1.pdf was setup with your rule but with 1 change:

 

if (cover = FusionPro.Composition.inputRecordNumber % 50 == 1)

FusionPro.Composition.repeatRecordCount = 1;

 

var page = (cover && FusionPro.Composition.repeatRecordNumber == 1) ? 'cover' : 'pad';

 

FusionPro.Composition.SetBodyPageUsage(page,true);

FusionPro.Composition.SetBodyPageUsage(page + '-back', true);

 

This composes to close to what I am needing - but not quite. It only composes 49 total sheets - starting with 0010002 instead of 0010001.

 

But if I use your rule as provided:

 

if (cover = FusionPro.Composition.inputRecordNumber % 50 == 1)

FusionPro.Composition.repeatRecordCount = 2;

 

var page = (cover && FusionPro.Composition.repeatRecordNumber == 1) ? 'cover' : 'pad';

 

FusionPro.Composition.SetBodyPageUsage(page,true);

FusionPro.Composition.SetBodyPageUsage(page + '-back', true);

 

My composed file finishes like the file I provided named: 147316_Final2.pdf

 

Any help would be greatly appreciated!!

Help.zip

Edited by dbentley
uploaded files
Link to comment
Share on other sites

My composed file named 147316_Final1.pdf was setup with your rule but with 1 change:

if (cover = FusionPro.Composition.inputRecordNumber % 50 == 1)
   FusionPro.Composition.repeatRecordCount = [color="Red"]1[/color];

var page = (cover && FusionPro.Composition.repeatRecordNumber == 1) ? 'cover' : 'pad';

FusionPro.Composition.SetBodyPageUsage(page,true);
FusionPro.Composition.SetBodyPageUsage(page + '-back', true);

This composes to close to what I am needing - but not quite. It only composes 49 total sheets - starting with 0010002 instead of 0010001.

Okay, so, maybe an explanation of what the code is doing would be helpful:

The 'cover' variable is set to true when the modulus of the input record number and 50 is 1. It looks confusing but you can just think of it as a counter that counts up to 50 and then starts over at 1. So the first record % 50 == 1, the 51st record % 50 == 1, etc.

 

We use that information to determine which records will start the stack because we want to add a cover sheet to them. Instead of actually adding in additional records for "covers," we're just going to repeat that record twice – once as a cover and once as a "pad". Without repeating the record, you'll eliminate that record from the "pad" and it will only show as the "cover" sheet and that's why your sequential numbering seems off when you use the above rule.

 

But if I use your rule as provided:

if (cover = FusionPro.Composition.inputRecordNumber % 50 == 1)
   FusionPro.Composition.repeatRecordCount = 2;

var page = (cover && FusionPro.Composition.repeatRecordNumber == 1) ? 'cover' : 'pad';

FusionPro.Composition.SetBodyPageUsage(page,true);
FusionPro.Composition.SetBodyPageUsage(page + '-back', true);

My composed file finishes like the file I provided named: 147316_Final2.pdf

 

Any help would be greatly appreciated!!

With my above explanation in mind, you need to consider that adding a cover sheet to a stack of 50 pads results in a stack of 51 pads. Perhaps the simplest solution is to set your stack height (plus 1 for the cover sheets) in your FPI file and build the template off of that information. That way you can set the stack height to 3 (for a stack of 2 pads and 1 cover sheet) and your sequence numbers and stacking would adapt. To do that you can make these changes:

 

JavaScript Globals:

var stackHeight = 1;

 

OnJobStart:

FusionPro.Composition.forcePreprocessing = true;
FusionPro.Composition.chunksBreakStacks = true;

// Get the name of the FPI file from the cfg file
var fpiFile = FusionPro.Composition.JobOptions["ImpositionDefFileName"];

// Import the .fpi file as an external data file delimited by returns (\n)
var ex = new ExternalDataFileEx(fpiFile,'\n');

// Print Error if the template can't link to the fpi file
if(!ex.valid) Print('* Failed to link to the FPI file in OnJobStart. Assuming 1 up *');


for (var i=0; i<=ex.recordCount; i++){
   var [prop,val] = ex.GetFieldValue(i,0).split("=");
   if ( val == 'Stack' ) 
       stackHeight = Int(ex.GetFieldValue(i-1,0).split('=').pop()) - 1;
}

 

OnRecordStart:

if (cover = FusionPro.Composition.inputRecordNumber % stackHeight == 1)
   FusionPro.Composition.repeatRecordCount = 2;

var page = (cover && FusionPro.Composition.repeatRecordNumber == 1) ? 'cover' : 'pad';

FusionPro.Composition.SetBodyPageUsage(page,true);
FusionPro.Composition.SetBodyPageUsage(page + '-back', true);

 

Range Rule:

var start = FusionPro.Composition.inputRecordNumber + 10000;
var end = start + stackHeight -1;
return FormatNumber('0000000', start) + ' to ' + FormatNumber('0000000', end);

 

Unfortunately, having less than 60 stacks of 51 pages, will result in undesirable results because of the way telescoping works in FusionPro. If you'd like to have fixed stack heights – meaning a stack height of "51" will result in a 51 page PDF whether you have 1 record or 60 records, I touch on a way to do that in this thread.

Link to comment
Share on other sites

Genius Ste!

 

I wasn't able to get the file to auto batch, but I was able to compose the batches manually in order to get the desired print file stacks.

 

I finished up my job on Friday. Thanks so much for making my weekend brighter by having this job moving forward.

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...