Main Content

Create Title Pages

You can add a title page to your report using the mlreportgen.report.TitlePage class. It is much easier and more efficient to use this class rather than using DOM objects to create and add a title page to your report. This class has predefined holes and formatting for the:

  • Title

  • Subtitle

  • Image

  • Author

  • Publisher

  • Publication date

You can exclude items you do not want on your title page and you can edit the TitlePage template to add more items.

This example shows code that creates a title page, which uses default formatting.

Run the following command to access the supporting files used in this example.

openExample('rptgen/MatlabReportGeneratorSupportFilesExample');
import mlreportgen.report.*
rpt = 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(rpt,tp);
close(rpt);
rptview(rpt);

The report title page has the title, Aircraft Tests, subtitle, Monthly Data, an image of a Boeing 747, author, John Smith, publisher, MathWorks, and the date.

For information and more examples, see mlreportgen.report.TitlePage.