Jump to content

Omit Pages During Composition?


Recommended Posts

Hello Hive Mind,

I have another challenge. Suppose I have a job that is 8 pages. Across said 8 pages, variable text will appear however, not every record will need all 8 pages. For example:

Record 1 - might need all 8 pages to display all necessary text.
Record 2 - might need only need pages 1 and 2 to display all necessary text.
Record 3 - might need pages 1-4 to display all necessary text.
ETC.

Since the shell file is 8 pages, the question is: is there a way that when composing the job that (in the above example of record 2), pages 3-8 are omitted from the composed document? The idea is that for each record, there are no "empty" pages in the final composed file.

TIA,
hp

Link to comment
Share on other sites

Hi Dan,

Thank you for the reply. Unfortunately, when I posted my question last night, I did not have all the information so I apologize for that. Here's what I am being told now:

The total number of possible pages for a single record is 8 (they are being called "header pages"). The data source contains 8 columns (one column for each header page). Each header page will contain 1 text frame (and within it, the corresponding field from the data source).

So, in the previous example, if all 8 columns within the data source are populated for record 1, then all 8 header pages will get composed however, on record 2, only columns A and B are populated, so the composed document will only contain pages 1 and 2 for record 2, and etc.

So, if the variable on a header page is empty, that page is suppressed from the composed document. Can this be done?

I hope this makes sense.

Thank you,
hp

Link to comment
Share on other sites

Okay, so based on that additional information, there are several ways you can accomplish this.

Method 1: Create a series of Unused Body Pages, with names such as "Header 1", "Header 2", etc.  Then in the OnRecordStart rule, you can call FusionPro.Composition.SetBodyPageUsage to activate the pages as needed.  I can't tell you exactly what the code should be without seeing your job files, or at least the data, but it would be something like this:

for (var i = 1; i <= 8; i++)
	FusionPro.Composition.SetBodyPageUsage("Header " + i, Trim(Field("Header Data " + i)) != "");

Please refer to the sections "How to switch body pages during composition" in both the User Guide and the Rules Guide for more information, or search this forum for "SetBodyPageUsage" for lots of other examples.

Method 2: If the job contains only these "Header" pages, and nothing else, you can accomplish this with a single page job, with a single text frame, and some code in OnRecordStart.  Again, not having your data file, I have to guess a bit at your field names, but it would be something like:

var HeaderData = [];
for (var i = 1; i <= 8; i++)
    HeaderData.push(Trim(Field("Header Data " + i)));

HeaderData = HeaderData.filter(String); // remove empty items

FusionPro.Composition.repeatRecordCount = HeaderData.length;
FusionPro.Composition.AddVariable("Header", HeaderData[FusionPro.Composition.repeatRecordNumber - 1], FusionPro.inputTreatFlatDataAsTagged);

Then you can go to the Text Frame, edit the text, and in the Variable Text Editor dialog, type "Header" (without quotes) into the Variable box, and click Insert.

Method 3: Use a Repeatable Component with the text frame in it, and insert instances of the Repeatable Component for populated data fields into a Body page text frame, which overflows to an Overflow page.  This is a bit more complex; I can provide more information if you want to go this route.
 

 

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