Main Content

mlreportgen.dom.PageBreakBefore Class

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

This class is only compatible with these MATLAB® Report Generator™ output types:

  • "docx"

  • "pdf"

  • "pdfa" (since R2025a)

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

Creation

Description

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

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

example

Input Arguments

expand all

Whether to start paragraph on new page, specified as a logical 1 (true) or 0 (false). When you specify:.

  • 1 (true) — Starts a paragraph on a new page.

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

Data Types: logical

Properties

expand all

Whether to start paragraph on new page, specified as a logical 1 (true) or 0 (false). When you specify:.

  • 1 (true) — Starts a paragraph on a new page.

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Tag, specified as a character vector or string scalar. The DOM API 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. Use this value to help identify where an issue occurs during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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