mlreportgen.dom.PageRef class

Package: mlreportgen.dom

Create placeholder for reference to page number of link target


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.


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


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.

Output Arguments

expand all

Name of link target to reference, returned as an mlreportgen.dom.PageRef object. This PageRef object is replaced with the number of the page containing the specified LinkTarget object.


expand all

This read-only property lists child elements of this object.

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. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

This read-only property lists the parent of this document element.

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

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





Copy this object.


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

% 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';

% 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.');

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


Introduced in R2016a