Jump to content

Setting pages to unused


Recommended Posts

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!
Link to comment
Share on other sites

One way to do that is to add this to your OnRecordStart callback rule:

// 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:

// 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; }
}

Edited by step
Forgot to define a variable
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

for example, I was looking to do something like this:

 

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:

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

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

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