Main Content

mlreportgen.dom.PageRef Class

Namespace: mlreportgen.dom

Create placeholder for reference to page number of link target

Description

Create a placeholder for a reference to the page number of a link target. This object applies only to Word and PDF output. For Word output, opening a document causes Word to replace this object with the page number of the link target that this object specifies. For PDF output, the DOM API replaces this object with the page number of the link target that it specifies.

Tip

Use this object to generate page references, such as "See page 15 for more information."

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

Creation

Description

example

pageRef = PageRef(target) creates a page reference object that refers to the specified LinkTarget object. Generating the output replaces this PageRef object with the number of the page that contains the specified target.

Input Arguments

expand all

Name of the link target to reference, specified as a character vector. Specify the target using a LinkTarget object.

Properties

expand all

Custom attributes of this document element, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be supported by the output format of the document element to which this object is appended.

Attributes:

NonCopyable
true

Format specification for this document element object, specified as an array of format objects. The formats specified by this property override corresponding formats specified by the StyleName property of this element. Formats that do not apply to this element are ignored.

Attributes:

NonCopyable
true

Data Types: cell

Style name, specified as a character vector or a string scalar. The style name is the name of a style specified in the style sheet of the document or document part to which this element is appended. The specified style defines the appearance of this element in the output document unless overridden by the formats specified by the Style property of this element. To learn more about using style sheets, see Use Style Sheet Styles.

Note

Microsoft® Word output ignores the style name.

Attributes:

NonCopyable
true

Data Types: char | string

Name of the target of this page reference, specified as a character vector.

Parent of mlreportgen.dom.PageRef object, specified as a document element object. A document element must have only one parent.

Attributes:

SetAccess
private
NonCopyable
true

Children of mlreportgen.dom.PageRef object, specified as an array of document element objects. This property contains the document element objects appended using the append method.

Attributes:

SetAccess
private
NonCopyable
true

Tag for mlreportgen.dom.PageRef object, 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. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

Object identifier for mlreportgen.dom.PageRef object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse all

This example inserts a page number reference to a target on another page. Add a target mytarget using LinkTarget. Use PageRef to refer to the page that contains the target mytarget.

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

% Create page footer and add page number to it
footer = PDFPageFooter('default');
d.CurrentPageLayout.PageFooters = footer;
d.CurrentPageLayout.FirstPageNumber = 1;
pageno = Paragraph();
pageno.HAlign = 'center';
append(pageno,Page());
append(footer,pageno);

% Add target to heading object and append heading and para text to document
h = Heading1(LinkTarget('mytarget'));
append(h,'Head Whose Page to Reference');
p = Paragraph('Here is some paragraph text.');
append(d,h);
append(d,p);

% Add another page and insert page reference to target
p1 = Paragraph('The following paragraph contains the page reference.');
p1.Style = {PageBreakBefore(true)};
p2 = Paragraph('See Page ');
p2.WhiteSpace = 'preserve';
ref = PageRef('mytarget');
append(p2,ref);
append(p2,'.');
append(d,p1);
append(d,p2);

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

Version History

Introduced in R2016a