Main Content

Create Chapters

This example shows how to create a chapter that contains a title page in landscape page orientation.

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

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("b747.jpg")));

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

Chapter one with a picture of a Boeing 747.

See Also