Main Content

Create Chapters

You can add chapters to your report using the mlreportgen.report.Chapter class. It is much easier and more efficient to use this class rather than using DOM objects to create a chapter. The Chapter class inherits from mlreportgen.report.Section.The Chapter class automatically adds a formatted chapter into your report. The default formatting is portrait orientation with a header and a footer. The footers includes the page number. You can override the layout of the chapter.

For information and examples, see mlreportgen.report.Chapter.

This example shows code that creates a title page and sets its page orientation to landscape.

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

openExample('rptgen/MatlabReportGeneratorSupportFilesExample');
import mlreportgen.report.*
import mlreportgen.dom.*

rpt = Report('My Report','pdf');

add(rpt,TitlePage('Title','My Report'));

chapter = Chapter('Images');
chapter.Layout.Landscape = true;
add(chapter,Section('Title','Boeing 747', ...
     'Content',Image(which('b747.jpg'))));

add(rpt,chapter);
close(rpt);
rptview(rpt);

Chapter one with a picture of a Boeing 747