Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mlreportgen.dom.PageBreakBefore class

Package: mlreportgen.dom
Superclasses:

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.

Construction

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

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

Output Arguments

expand all

Page break before format, returned as an mlreportgen.dom.PageBreakBefore object.

Properties

expand all

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

Tag for document element, specified as a character vector.

A session-unique ID is generated as part of document element creation. The generated tag has the form CLASS:ID, where CLASS is the class of the element and ID is the value of the Id property of the object. You can specify a tag to replace the generated tag.

For example, to make it easier to identify where an issue occurred during document generation, you can specify your own tag value.

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

expand 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);
Was this topic helpful?