Conditional Breaks

Some of you have requested a sample of the new Conditional Breaks feature in Designer 7.1.

This feature allows you to set conditions, based on imported data, which determine when breaks should occur.

For example, you may have data that you want to list by category and every time the category changes, you’d like to start the new category on a new page. Or, you may have a separator that you want to insert in between sets of data on your form.

I’ve created a little sample which demonstrates the Conditional Breaks feature by listing some movie data where each time the category changes, a new page starts. Don’t forget to import the data.xml file into the form when you open it in Acrobat.

“Download Sample [zip]”:http://blogs.adobe.com/formbuilder/samples/ConditionalBreaks.zip

*Minimum Requirements:* Designer 7.1, Acrobat 7.0.5.

*Note:* A basic understanding of Data Binding is required for this sample.


Since breaks are only really useful inside flowed subforms (there’s no point setting breaks on a subform inside a positioned container since the data won’t flow — it’ll all stay in one place instead of flowing left-to-right, top-to-bottom, for example), you can only get to the Conditional Break settings on the Object palette’s Pagination tab if you select a subform inside a flowed container (subform). The only exception is selecting a row or a section within a Table object since the content of Tables is always flowed.Typically, after creating a new form, you would add a positioned subform (let’s call it the ContentSubform) to the page and add the fields you need into it. You would then make the page subform flowed (set the Content property on the Object palette’s Subform tab to [_Flowed_]), then select the ContentSubform and click on the _Edit_ button on the Object palette’s Pagination tab. This will open the Conditional Breaks Dialog where you can add multiple conditions for that subform’s breaks.In my sample, the data represents movies and each movie record has the following information:* Category* Title* ActorSince I wanted to create a report-style form where a change in category breaks to a new page and a change in the actor’s name is preceeded by a separator, I created a *movie* subform which lists the data and then two other subforms:# *NewCategorySF* which I want to insert every time the category changes.# *NewActorSF* which I want to insert every time the actor’s name changes.I then specified two conditional breaks on the *movie* subform:# The first one checks for a change in the category data. When a change occurs, the layout will break to the top of a new instance of the “page 1” subform and, before starting to list the data for the new category, insert an instance of the *NewCategorySF* subform. This is what we call a _Break Before_ Conditional Break (since the break occurs _before_ the new record, which contains the new category name, is inserted into the form). Notice that the *NewCategorySF* subform is listed as a _Leader_ for the Conditional Break because it’s meant to be inserted after the break but before the new record gets inserted into the form.# The second checks for a change in the actor data. When a change occurs, the layout will not actually break because we simply want to use the Conditional Break to know when to insert the *NewActorSF* to separate the data set into sub-groups of actors. In this case, I specified *NewActorSF* to be a _Leader_ for the Conditional Break because I wanted it to show-up after the actual break but before the new record is inserted into the form. You may wonder why I didn’t make it a _Trailer_ but in this case, there wouldn’t be any difference since there isn’t an actual “physical” break in the data flow (to a new page or content area, for example).Also notice that the *NewCategorySF* and *NewActorSF* subforms are both set to _Repeat for Each Data Item_ (you can set this on the Object palette’s Binding tab) with a _Min Count_ of 1 so that they always appear before the very first data record is inserted into the form. Otherwise, they wouldn’t appear until the first Conditional Break occurs.

7 Responses to Conditional Breaks

  1. Cindy says:

    The link to this site isn’t working…has it moved?thanks

  2. Cindy,The only link in this post is the one to the sample file. I just tried it and it worked fine for me. Please give it another try. It’s possible the server was in the process of rebuilding my blog at the moment when you tried to download the file.

  3. jay says:

    This is very interesting site

  4. Hi StefanI noticed that if you specify a leader or trailer subform, and that subform is set to “Flowed”, then the form doesn’t render properly. This is quite simple to try. Do you have an magic for making this work?Many thanks,Howard

  5. Howard,I’m going to take a guess as assume that you’re seeing an extra page immediately when you create the Conditional Break.This can happen if you haven’t yet set a condition script for the break because having no condition script is the same as having a condition script that always returns true and therefore always causes the break to execute.Since Designer’s WYSIWYG design-time rendering tries to execute the breaks that it can, it immediately executes the conditional break you just specified simply because it has no condition.Try specifying a condition script and see what happens. The form should go back to “normal”.

  6. Varun Shah says:

    Hi ,I have one doubt.If a table has 20 records(i.e Rows ) , I want to write a conditional break statement in such a way that i should display first 10 records from the table and after some pages, I should be able to display the remaining data from the table.

  7. Varun,I decided to enlist the help of a colleague of mine here at Adobe in order to answer your question. Here’s what he said:————————–Since form content is laid out in a contiguous manner, there is no stopping within a table (say after 10 rows), jumping to other form content, and then back to the other rows again.However, there are ways to break from one page to another and emit intermediate pages (“skip over pages”) along the way. Obviously the only objects on the “skipped over” pages will be whatever is defined as the master page content.Remember that pageAreas support occurrence information (<occur/> property) so you would use an ordered pageSet, and setup pages with <occur min=”1″/> in order to ensure these pages get emitted. Then, depending on how you wanted to group the pageAreas, you could ensure that when you break to a page “B”, that one or more intermediate pages were emitted.Here’s an example:<subform name=”root”>  <pageSet relation=”ordered”>    <pageArea name=”PageA”>      …page background objects…    </pageArea>    <pageArea name=”X”>      <occur min=”1” />      …page background objects…    </pageArea>    <pageArea name=”Y”>      <occur min=”1” />      …page background objects…    </pageArea>    <pageArea name=”PageB”>      …page background objects…    </pageArea>  </pageSet>  …form content…</subform>Say the first 10 rows were on “PageA”. A conditional break on the 11th row to “PageB” would cause one instance of page “X” and one instance of page “Y” to be emitted as well. Depending on how the form is designed, you may wish to protect against inadvertent X/Y instances coming out –- as it’s defined now X/Y will be emitted anytime you jump from “PageA” to any page defined lower down. This may or may not be desirable. To ensure that X/Y were emitted when a break to “PageB” occurred you could nest pageSets, something like this:<subform name=”root”>  <pageSet relation=”ordered”>    <pageArea name=”PageA”>      …page background objects…    </pageArea>    <!– This nested pageSet packages PageB with X/Y. Effectively any jump to PageB will cause X+Y to also be emitted –>    <!– Note that in such cases pages X/Y could be ‘boilerplate’ pages, i.e. pageAreas with no contentAreas –>    <pageSet relation=”ordered”      <pageArea name=”X”>        <occur min=”1”/>          …page background objects…      </pageArea>      <pageArea name=”Y”>        <occur min=”1”/>          …page background objects…      </pageArea>      <pageArea name=”PageB”>        …page background objects…      </pageArea>    </pageSet>  </pageSet>  …form content…</subform>AdamAdobe Systems————————–To summarize, you can do what you were asking but only to some degree since the pages that get “skipped” must be master pages (or “background content” as Adam referred to them). Fields you place on master pages will still be functional but they operate on a global basis rather than within the context of a page subform like body page fields do.Also, you’ll need to use the XML Source view in order to achieve the nested pageSet solution that Adam proposed since Designer doesn’t currently let you add pageSets (collections of master pages) in Design view. You can, however, use the “Restrict Page Occurrence” property on the Master Page tab of the Object palette (which you get when you select a master page using the Hierarchy palette) in order to set each page’s <occur min=”1″/> property.