While working on Aspose.Words for Reporting Services, we have been constantly thinking on how to maintain a good balance between the “editability” and appearance of the documents being generated. Produce documents as simple as possible, but don’t let layout and formatting suffer - that’s been our rule.

Following this rule is often difficult. RDL reports and Microsoft Word documents are basically very different things. RDL reports are easy to draw (for example, as a PDF document or image), but try to compose them from flow layout paragraphs and tables so that the design would not suffer - and you will understand what I mean.

RDL reports often contain page breaks. Lots of. There are page breaks before and after report items, before and after table groups, etc. How many page breaks should a Word document contain so that it would stay easy to edit?

Obviously, if there are too many breaks, working with the document may become a torture. But if there are too few, the layout may appear corrupted.

So far Aspose.Words for Reporting Services offered three modes affecting page breaks placement. The active mode is controlled by the PageBreaks configuration setting. The modes are:

  • Smart (default) - the engine decides how to place page breaks
  • OnEachPage - each page has a page break at its end
  • None - no page breaks in the document at all

The latter two modes are just plain, while the first one is interesting. How should the algorithm work to produce an optimal quantity of page breaks? At what points page breaks are necessary and where they can be omitted?

Apparently, page breaks must appear where they are supposed to appear by designer. So the algorithm places explicitly specified breaks once encountered. Where else?

Before we answer the question, let’s talk a little about tables in Word documents. Most of RDL reports contain tables and matrices (Reporting Services 2005) or tablix items (Reporting Services 2008). These report items are converted to Word tables. So we can confidently state that most of documents generated by Aspose.Words for Reporting Services contain tables. Many tables commonly.

Tables in Word documents may not contain page breaks inside. If a table is split by a page break, there are two tables actually: before and after the break. And the more tables are in the document, the harder it is to edit by the users.

The conclusion is: avoid breaking tables whenever possible.

That’s how the algorithm works. Starting with version 3.1.0, it uses the Word’s “Repeat as header row at the top of each page” feature to represent repeatable headers. That allows to keep the table continuous and avoid excessive breaks.

Unfortunately, there are two special cases that still make breaking the table inevitable:

  • Repeatable headers change throughout the table
  • The table contains repeatable footers

Luckily, those are not very frequent cases, based on my experience.

But what if you need your tables to be unbroken at all? Remember, broken table is multiple tables. Imagine you want to work with a table as a whole instead of a bunch of its pieces, one per page.

You could set PageBreaks to None, but then all page breaks will disappear from the document. That is not nice, for instance, if you still want your table aligned with the beginning of a page and therefore inserted a page break before. So what you need is page breaks retained all over the document except tables.

That’s why we have just introduced the fourth mode - DontBreakTables. It preserves explicit page breaks outside the tables thus keeping tables unbroken but making the rest of the document as close to the original design as possible.

It works just fine if your table has no repeatable headers or they don’t change throughout the table - in the latter case they will simply be marked with the “Repeat as header row at the top of each page” attribute like if you did that manually. But if they do change, or if your table have repeatable footers - there is no guarantee headers and footers will appear at the beginning and end of the page, respectively. This is a trade-off because you have instructed the engine to omit page breaks within tables.

Choose a page breaks mode that suits your needs the best and enjoy the editing!

To download the latest Aspose.Words for Reporting Services 3.1.0, please visit http://www.aspose.com/community/files/52/ssrs-rendering-extensions/default.aspx