Main Content

mlreportgen.dom.PageBreakBefore class

Package: mlreportgen.dom

Start paragraph on new page

Description

Specifies to always start the associated paragraph on a new page. This class applies to Microsoft® Word and PDF reports.

The mlreportgen.dom.PageBreakBefore class is a handle class.

Creation

Description

pageBreakBefore = PageBreakBefore() always starts the paragraph on a new page.

example

pageBreakBefore = PageBreakBefore(onOff) always starts paragraph on a new page if onOff is true.

Input Arguments

expand all

Option to start paragraph on new page, specified as one of these values:

  • true or 1 — Starts a paragraph on a new page.

  • false or 0 — Allows a paragraph to start on the current page.

Data Types: logical

Properties

expand all

ID for this document element, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Tag for this document element, specified as a character vector or string scalar.

The DOM generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specifying your own tag value can help you to identify where an issue occurred during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Option to start paragraph on new page, specified as one of these values:

  • true or 1 — Starts a paragraph on a new page.

  • false or 0 — Allows a paragraph to start on the current page.

Data Types: logical

Examples

collapse all

This example shows how to apply the PageBreakBefore property to a heading paragraph. The example uses two approaches for applying properties. The first creates a PageBreakBefore object whose value is explicitly true. You can then assign that format object to the heading’s Style property. The second approach sets the property on the heading object without explicitly creating a PageBreakBefore object.

import mlreportgen.dom.*;
d = Document('mydoc','docx');
open(d);

% Create first page text
t = Heading(1,'Document Title','Title');
h = Heading(2,'My Head','Heading1');
p = Paragraph('Hello World');

append(d,t);
append(d,h);
append(d,p);

% Create a heading paragraph h1
% Create a PageBreakBefore object and set it as a Style property on h1
h1 = Heading(2,'My Second Head','Heading1');
br = {PageBreakBefore(true)};
h1.Style = br;
p1 = Paragraph('Another page');

% Create a heading paragraph h2
% Set the h2 Style property to use PageBreakBefore set to true
h2 = Heading(2,'My Third Head','Heading1');
h2.Style = {PageBreakBefore()};
p2 = Paragraph('My third page');

append(d,h1);
append(d,p1);
append(d,h2);
append(d,p2);

close(d);
rptview(d.OutputPath);

Version History

Introduced in R2014b