Automatic Text Break

<< Click to Display Table of Contents >>

Navigation:  Programming Techniques > Dynamic Positioning >

Automatic Text Break

Previous pageReturn to chapter overviewNext page

This is a very powerful feature! VPE is able to render text to the bottom margin (i.e. the defined bottom of the output rectangle) and to insert the remaining text automatically onto successive pages. If there is no successive page, VPE will generate a new blank page.

The AutoBreak does only work for Text and RichText, not for images, boxes or any other objects.

 

Text / RTF is broken to the next page only if

nBottom of the object  > nBottomMargin

 

NOTE: Due to round-off problems, VPE allows for Text and RTF a possible maximum tolerance of 0.3 mm by which nBottom may exceed nBottomMargin without firing an auto break.

VPE knows the following different Auto Break Modes:

AUTO_BREAK_ON

Auto Break is activated. An Auto Break will happen if y2 = VFREE or y > VBOTTOMMARGIN.

Remaining text is broken onto the next page(s) with the following coordinates:

x

=

the original x coordinate of the inserted object

x2

=

the original x2 coordinate of the inserted object

y

=

top of the Output Rectangle of the successive page - if a new page is generated, it will be the top of the Default Output Rectangle

y2

=

VFREE

 

AUTO_BREAK_OFF

Same behavior as AUTO_BREAK_ON (limited positioning / rendering to the bottom of the output rectangle is active), but remaining text is NOT broken onto next page(s). It is cut instead.

 

AUTO_BREAK_NO_LIMITS

Remaining text is NOT broken onto the next page(s), it can be placed anywhere on the paper with no limits.

 

AUTO_BREAK_FULL

Auto Break is activated. An Auto Break will happen if y2 = VFREE or y > VBOTTOMMARGIN.

Remaining text is broken onto the next page(s) with the following coordinates:

x

=  

left margin of the Output Rectangle

x2

=  

right margin of the Output Rectangle

y

=  

top margin of the Output Rectangle

y2

=  

VFREE

NOTE: If a new blank page is added by VPE, the Default Output Rectangle will be used to set x, x2 and y. Otherwise if the next page is already existing, the Output Rectangle of the existing page is used. You can modify the Output Rectangle of an existing page at any time.

 

By using the AutoBreakMode feature in conjunction with the Default Output Rectangle, you can control on what position broken text is placed on successive pages.

Examples:

DLL:

VpeSetAutoBreak( hDoc, AUTO_BREAK_OFF );

 

Control:

<Object>.AutoBreakMode = AUTO_BREAK_OFF

 

The default after calling OpenDoc() is AUTO_BREAK_ON. For a detailed example take a look at the Auto Render Demo in the source code of VPEDEMO.

 

For RTF AutoBreak features, see "Build-In Paragraph Setting: RTF Auto Page Break".

 

VPE fires also an event, if an AutoBreak occurs. This gives you additional control over the layout. When the event is fired, VPE already moved to the next page (or generated one) and you can modify the Output Rectangle (NOT the Default Output Rectangle) to control the layout, or insert manually Headers and Footers, etc. (see also "Headers and Footers").

The event is named:

DLL: VPE_AUTOPAGEBREAK
Control: AfterAutoPageBreak
VCL: OnAutoPageBreak

 

NOTE: VPE might enter an endless loop, if you specify the page dimensions and or the page margins in a way, so that the output rectangle is smaller than the space required for at least one line of text. If you output text in such case, VPE can not print a single line of the text on the current page and creates an auto break. On the new page the output rectangle is again too small (there is no additional space) and VPE fires again an auto break, and so forth.
 
Especially if you are printing on labels, change the margins accordingly. Best, you set the margins to the page boundaries, or set AutoBreakMode = AUTO_BREAK_OFF while processing the event.

 

Enterprise and Interactive Editions Only:

The Enterprise and Interactive Editions do also break all other objects as whole to the next page if - and only if - they are dumped from a template.

In addition, the DumpTemplate()-methods do not make any differences between the AutoBreakModes AUTO_BREAK_ON and AUTO_BREAK_FULL, i.e. objects are always inserted into the current VPE Document with the given left and right coordinates if one of both modes is set.

If a template object is defined with Top = dynamic, it will not be broken backwards to previous pages. Also, an object with Top = dynamic is not broken to the next page, if the bottom of the object runs below the bottom margin. Therefore use the Top = dynamic setting with care, it is always better to use bottom = dynamic within a dependency chain. In contrast it is no problem to use Top = dynamic if Bottom = fixed.