Main Content

mlreportgen.dom.PageRef class

Package: 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

Children of this document element, specified as an array of DOM objects. This property is read-only.

Custom attributes of this element, specified as an array of mlreportgen.dom.CustomAttribute objects. Use custom attributes supported by the output format.

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

Parent of this document element, specified as a DOM object. This property is read-only.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Format objects that specify the format of a document element.

Name of the style to apply from the style sheet, specified as a character vector.

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

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

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