主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

mlreportgen.dom.PageBreakBefore 类

命名空间: mlreportgen.dom

在新页面开始段落

描述

指定始终在新页面上开始相关段落。此类适用于 Microsoft® Word 和 PDF 报告。

mlreportgen.dom.PageBreakBefore 类是一个 handle 类。

创建对象

描述

pageBreakBefore = PageBreakBefore 总是在新页面开始段落。

如果 onOfftrue,则 pageBreakBefore = PageBreakBefore(onOff) 总是在新页面开始段落。

示例

输入参量

全部展开

在新页面上开始段落的选项,指定为以下值之一:

  • true1 - 在新页面上开始一个段落。

  • false0 - 允许段落从当前页开始。

数据类型: logical

属性

全部展开

目标标识符,指定为字符向量或字符串标量。DOM API 在创建文档元素对象时会生成一个会话唯一标识符。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

标记,指定为字符向量或字符串标量。DOM API 在创建此对象的过程中生成一个会话唯一标记。生成的标记形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。使用此值来帮助确定在文档生成过程中出现的问题的位置。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

在新页面上开始段落的选项,指定为以下值之一:

  • true1 - 在新页面上开始一个段落。

  • false0 - 允许段落从当前页开始。

数据类型: logical

示例

全部折叠

此示例显示如何将 PageBreakBefore 属性应用于标题段落。该示例使用了两种方法来应用属性。第一个创建一个其值明确为真的 PageBreakBefore 对象。然后,您可以将该格式对象分配给标题的 Style 属性。第二种方法是在标题对象上设置属性,而无需明确创建 PageBreakBefore 对象。

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);

版本历史记录

在 R2014b 中推出