MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   FusionPro® VDP Producer (formerly FusionPro® Direct) (http://forums.pti.com/forumdisplay.php?f=14)
-   -   Setting pages to unused (http://forums.pti.com/showthread.php?t=4827)

mjlongo March 7th, 2017 08:50 AM

Setting pages to unused
 
Hello, our customer will be providing a document to use that may contain 100's or 1000's of pages. The job will require that only select pages as well as a separate variable page will be used for each record. Is there a way to quickly set all of the pages to unused? I certainly will not want to go mark every page as unused manually. Thanks!

step March 7th, 2017 09:31 AM

Re: Setting pages to unused
 
One way to do that is to add this to your OnRecordStart callback rule:
Code:

// List of pages that should be enabled in your template
var enabledPages = [
  4,
  10,
  11,
];
var totalPages = 1000; // Total number of pages in your template
for (var page = 1; page <= totalPages; page++) {
  FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1);
}

You can also get away with not defining the total number of pages in your document by using this code instead:
Code:

// List of pages that should be enabled in your template
var enabledPages = [
  4,
  10,
  11,
];

var page = 0;
while (++page && !FusionPro.inValidation) {
  try {
    FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1);
  } catch(e) { break; }
}


mjlongo March 7th, 2017 10:05 AM

Re: Setting pages to unused
 
Step, thank you for that response. That sets me off in the right direction. I did run into one problem however.

The enabledPages variable that is being set at the beginning does not seem to want to take in the field. for example, I was looking to do something like this:

enabledPages = [field("record number"), 101]

So that page "record number" (maybe equals 1) would be the valid page for that record as well as page 101. The next record in the document might end up calling out page 5 and so on.

I hope that makes sense.

step March 7th, 2017 10:49 AM

Re: Setting pages to unused
 
Quote:

Originally Posted by mjlongo (Post 19800)
The enabledPages variable that is being set at the beginning does not seem to want to take in the field.

Not sure what you mean by that. Are you getting an error that gives you that impression? Could you share it?
Quote:

Originally Posted by mjlongo (Post 19800)
for example, I was looking to do something like this:

Code:

enabledPages = [field("record number"), 101]

Are you entering it exactly like that? If so, you need to capitalize the "field" function so that it pulls in your field value correctly. The only other thing I could think that you might want to try is ensuring that all of your variables are of the same type. In my example, all of the numbers in the array were integers being compared to integers. This might help:
Code:

// List of pages that should be enabled in your template
var enabledPages = [Field("record number"), 101].map(Int);

var page = 0;
while (++page && !FusionPro.inValidation) {
  try {
    FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1);
  } catch(e) { break; }
}


mjlongo March 7th, 2017 11:46 AM

Re: Setting pages to unused
 
Step, the .map(Int) part is all that I needed. The job works now. Thanks!!


All times are GMT -7. The time now is 08:24 PM.

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