Jump to content

Page Usage not working as excpeted


bkurzbuch

Recommended Posts

Mac OS Sierra 10.12.6, Acrobat 11.0.22 & FusionPro 9.3.36

 

I have a 12 page document which should output just 2 pages per record based on field"Letter Type". I have named all pages 1 through 12 and set them all to unused. The code below is On Record start to use just the 2 pages I need based on a code in the "Letter Type" Field, but doesn't seem to be working. Where is my syntax wrong? Thank You for looking

 

switch (Field("Letter Type"))
{
 case "ARNOT18 YP1 ACH-CC SNGL T":
   FusionPro.Composition.SetBodyPageUsage("1",true);
   FusionPro.Composition.SetBodyPageUsage("2",true);
   break;
 case "ARNOT18 YP1 ACH-CC INST T":
   FusionPro.Composition.SetBodyPageUsage("3",true);
   FusionPro.Composition.SetBodyPageUsage("4",true);
   break;
 case "ARNOT18 PHY RES ACH-CC SNGL":
   FusionPro.Composition.SetBodyPageUsage("5",true);
   FusionPro.Composition.SetBodyPageUsage("6",true);
   break;
   case "ARNOT18 PHY RES ACH-CC INST":
   FusionPro.Composition.SetBodyPageUsage("7",true);
   FusionPro.Composition.SetBodyPageUsage("8",true);
   break;
   case "ARNOT18 PHY ACH-CC INST T":
   FusionPro.Composition.SetBodyPageUsage("9",true);
   FusionPro.Composition.SetBodyPageUsage("10",true);
   break;
   case "ARNOT18 PHY ACH-CC SNGL T":
   FusionPro.Composition.SetBodyPageUsage("11",true);
   FusionPro.Composition.SetBodyPageUsage("12",true);
   break;
 default:
   ReportError("Can't set pages for Letter Type: " + Field("Letter Type"));
}

Link to comment
Share on other sites

The code below is On Record start to use just the 2 pages I need based on a code in the "Letter Type" Field, but doesn't seem to be working.

Please elaborate on "doesn't seem to be working?" What is the expected result, and specifically how is it different from the actual result?

 

Have you looked in the composition log (.msg) file for any relevant messages? Does your "Can't set pages for Letter Type" message appear? Or something else?

Where is my syntax wrong? Thank You for looking

Are your pages named? If not, then you want to use page numbers rather than strings in the calls to FusionPro.Composition.SetBodyPageUsage. In other words, you want to remove the quotes from around the page numbers, like so:

    FusionPro.Composition.SetBodyPageUsage(1, true);

The code can also be reduced in several ways, such as:

var pages = [];
switch (Field("Letter Type"))
{
 case "ARNOT18 YP1 ACH-CC SNGL T":
   pages = [1,2];
   break;
 case "ARNOT18 YP1 ACH-CC INST T":
   pages = [3,4];
   break;
 case "ARNOT18 PHY RES ACH-CC SNGL":
   pages = [5,6];
   break;
 case "ARNOT18 PHY RES ACH-CC INST":
   pages = [7,8];
   break;
 case "ARNOT18 PHY ACH-CC INST T":
   pages = [9,10];
   break;
 case "ARNOT18 PHY ACH-CC SNGL T":
   pages = [11,12];
   break;
 default:
   ReportError("Can't set pages for Letter Type: " + Field("Letter Type"));
}

for (var i in pages)
   FusionPro.Composition.SetBodyPageUsage(pages[i], true);

Or even:

var types = ["ARNOT18 YP1 ACH-CC SNGL T", "ARNOT18 YP1 ACH-CC INST T", "ARNOT18 PHY RES ACH-CC SNGL",
               "ARNOT18 PHY RES ACH-CC INST", "ARNOT18 PHY ACH-CC INST T", "ARNOT18 PHY ACH-CC SNGL T"];
var index = types.indexOf(Field("Letter Type"));
if (index < 0)
   ReportError("Can't set pages for Letter Type: " + Field("Letter Type"));
//else
FusionPro.Composition.SetBodyPageUsage(index * 2 + 1, true);
FusionPro.Composition.SetBodyPageUsage(index * 2 + 2, true);

Link to comment
Share on other sites

Hi Dan

Thanks for your reply. My apologizes, I should have been more specific. Was operator error. I wrongly assumed it was a syntax error. I copied and pasted the different codes from Indesign instead of pulling from the data it self. My bad - Live and learn. I do have a quick questions so I understand this. If you do not name the pages, you can just call out to them by page number alone, correct?

 

Thanks again

Link to comment
Share on other sites

I do have a quick questions so I understand this. If you do not name the pages, you can just call out to them by page number alone, correct?

You can always call out pages by their body page numbers, regardless of whether they're named.

 

But naming the pages can be useful. For instance, you could give your pages names that match the field values, such as "ARNOT18 YP1 ACH-CC SNGL T 1" and "ARNOT18 YP1 ACH-CC SNGL T 2", etc., in which case the entire rule could be just two lines:

FusionPro.Composition.SetBodyPageUsage(Field("Letter Type") + " 1", true);
FusionPro.Composition.SetBodyPageUsage(Field("Letter Type") + " 2", true);

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