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.report.TitlePage class

Package: mlreportgen.report
Superclasses:

Title page reporter

Description

Create a title page reporter that adds a title page to a report. This class inherits from mlreportgen.report.Reporter.

Construction

tp = TitlePage() creates a title page reporter object that uses the default title page template. The title page template does not include a page number in the footer.

tp = TitlePage(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single quotes.

Properties

expand all

Table of contents title, specified as one of these values:

  • String or character array

  • DOM object

  • 1-by-N or N-by-1 array of strings or DOM objects

  • 1-by-N or N-by-1 cell array of strings, character arrays, and/or DOM objects

  • TitlePageTitle reporter

Example: tp.Title = 'My Report';

Table of contents title, specified as one of these values:

  • String or character array

  • DOM object

  • 1-by-N or N-by-1 array of strings or DOM objects

  • 1-by-N or N-by-1 cell array of strings, character arrays, and/or DOM objects

  • TitlePageSubtitle reporter

Example: tp.Subtitle = 'Part I';

Image to insert in title page, specified as one of these values:

  • String or character array that specifies the file system path of the image

  • Snapshot maker, such as an mlreportgen.report.Figure reporter.

  • DOM object

  • 1-by-N or N-by-1 cell array of image paths, snapshot makers, or DOM objects

  • TitlePageImage reporter

Supported image formats are:

  • .bmp – Bitmap

  • .gif – Graphics Interchange Format

  • .jpg – JPEG

  • .png – Portable Network Graphics

  • .emf – Enhanced metafile (supported only in .docx output on Windows)

  • .svg – Scalable Vector Graphic

  • .tif – Tag Image File

Example: tp.Image = 'reports/imagedir/titleimage.jpg';

Report author, specified as one of these values:

  • String or character array

  • DOM object

  • 1-by-N or N-by-1 array of strings or DOM objects

  • 1-by-N or N-by-1 cell array of strings, character arrays, and/or DOM objects

  • TitlePageAuthor reporter

Example: TitlePage('Author','John Smith')

Report publisher, specified as one of these values:

  • string or character array

  • DOM object

  • 1-by-N or N-by-1 array of strings or DOM objects

  • 1-by-N or N-by-1 cell array of strings, character arrays, and/or DOM objects

  • TitlePagePublisher reporter

Example: tp.Publisher = 'Smith Company';

Report publication date, specified as one of these values:

  • String or character array

  • DOM object

  • 1-by-N or N-by-1 array of strings or DOM objects

  • 1-by-N or N-by-1 cell array of strings, character arrays, and/or DOM objects

  • TitlePagePublDate reporter

Example: tp.PubDate = 'April 23, 2017';

Layout options for this reporter, specified depending on which layout property you set. The layout properties are Watermark, FirstPageNumber, PageNumberFormat, and Landscape. See mlreportgen.report.ReporterLayout for descriptions of these properties

Source of template for this reporter, specified as one of these values:

  • String or character array specifying the path of the file containing the template for this reporter

  • Reporter or report whose template is used as the template for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used as the template for this reporter or whose template library contains the template for this reporter

The specified template must be of the same type as the report to which this reporter is appended. For example, for a Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of template for this reporter, specified as a string or character array. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a string, character array that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A string or character array value is converted to a LinkTarget object. The link target object immediately precedes the content of this reporter in the output report.

Example: firstchapter.LinkTarget = 'ch1_link';

Methods

createTemplateCreate title page template
customizeReporterCreate custom title page reporter class
getAuthorReporterGet title page author reporter
getClassFolderTitle page class definition file location
getImageReporter Get title page image reporter
getPubDateReporterGet title page publication date reporter
getPublisherReporter Get title page publisher reporter
getSubtitleReporter Get title page subtitle reporter
getTitleReporterGet title page title reporter

Inherited Methods

getImpl Get implementation of reporter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

Default Title Page

Create a title page that uses the default formatting. Add the title page to the report and view the report.

import mlreportgen.report.*
report = Report('output','pdf');

tp = TitlePage();
tp.Title = 'Aircraft Tests';
tp.Subtitle = 'Monthly Data';
tp.Image = which('b747.jpg');
tp.Author = 'John Smith';
tp.Publisher = 'MathWorks';
tp.PubDate = date();

add(report,tp);
rptview(report);

Title Page with Customized Color

Create a title page that uses the default title format, but changes the title color to red. In this case, you specify the Title property as a DOM Text object and set its color to red.

import mlreportgen.report.*
import mlreportgen.dom.*

report = Report('output','pdf');
tp = TitlePage;
tp.Title = Text('Aircraft Tests');
tp.Title.Color = 'red';

add(report,tp);
rptview(report);

Override Title Page Title Formatting

Create a title page that overrides the title property formatting. Change the title font to 24 pt Arial, the title text color to white, and use a blue background. Any styles you do not specify use the mlreportgen.dom.Paragraph class defaults.

import mlreportgen.report.*
import mlreportgen.dom.*

report = Report('output','pdf');
tp = TitlePage();
title = Paragraph('Aircraft Tests');
title.Style = {HAlign('left'),FontFamily('Arial'),...
         FontSize('24pt'),Color('white'),...
         BackgroundColor('blue'),...
         OuterMargin('0in','0in','.5in','1in'),...
         HAlign('center')};
tp.Title = title;
tp.Subtitle = 'Monthly Data';
tp.Image = which('b747.jpg');
tp.Author = 'John Smith';
tp.Publisher = 'MathWorks';
tp.PubDate = date();

add(report, tp);
rptview(report);

Override Title Page Formatting and Layout Using Templates

The template for a TitlePage object determines its page orientation, page margins, page size, and other page layout properties. You can customize and override the title page layout using a customized version of its default template. You can also customize individual title page elements by customizing those element templates. The TitlePage reporter supports two approaches to overriding title page element templates.

Use Custom TitlePage Template

  1. Create a copy of the default title page template.

  2. Edit the title page element templates as desired in the copy of the template. The names of the templates have the form TitlePageNAME where NAME is the name of the template in the template library. For example, the name of the title template is TitlePageTitle.

  3. Set the TitlePage TemplateSrc property of the object to the path of the custom template.

Use a Different Template Library

This approach takes advantage of the fact that the TitlePage object uses specialized reporters, called hole reporters, to apply element templates to the elements. The TitlePage reporter provides methods for getting the reporter to apply a template to a particular element. For example, the getTitleReporter method returns the reporter used for applying the TitlePageTitle template to the content of the report title.

  1. Copy the title page element templates that you want to customize into a different template library. For example, you can copy the template library of the report or the template library of a DOM document part object. These template libraries are often libraries that you created to store customized versions of templates.

  2. For each title page element to be customized, get its element reporter. For example, for the title, use the getTitleReporter method.

  3. Set the TemplateSrc property of the element reporter to the source of the template library containing the customized version of the element template.

  4. Set Content property of the element reporter to the element content.

  5. Set the title page object element property to the element reporter object.

import mlreportgen.report.*
import mlreportgen.dom.*

rpt = Report('MyReport','pdf','MyCustomPDFTemplate');
tp = TitlePage;
titleReporter = getTitleReporter(tp);
titleReporter.TemplateSrc = rpt;
titleReporter.Content = 'My Report';
tp.Title = titleReporter;

Introduced in R2017b

Was this topic helpful?