Difference between revisions of "Report API"

From Gramps
Jump to: navigation, search
(Update with latest report types)
m ({{Out of date}})
Line 1: Line 1:
{{Out of date}}
In GRAMPS there are five different types of reports.
In GRAMPS there are five different types of reports.
* Text report
* Text report

Revision as of 02:30, 28 December 2012

This page's factual accuracy may be compromised due to out-of-date information. Please help improve the Gramps Wiki as a useful resource by updating it.

In GRAMPS there are five different types of reports.

  • Text report
  • Graphical report
  • Graph
  • Book
  • Web pages

Only Text reports, Graphical reports and Graphs use the Report (Document) API, since Web reports write their output directly into files, while Book reports are simply combination of Text reports and Graphical reports.

Common API

At the moment the combination of textual and graphical elements within one document is not supported (for future plans refer to Report API redesign), thus Text and Graphical reports are implemented via separate APIs, though they have a common part. This common part is implemented in the BaseDoc class, which contains among others basic document opening, closing, and stylesheet handling methods. It also stores the physical description of a page (sheet of paper in print).

Note! The BaseDoc.open and the BaseDoc.close methods have to be implemented by the subclassed document generators.


Doc paper.png
Description of the paper, which every report will be rendered on, is stored by an instance of the PaperStyle class. This instance is available via the BaseDoc.paper_style class attribute. The chosen PaperStyle is given to the document generator at initialization, and is handled by the reporting framework.

The PaperStyle holds information on the size of the paper (PaperSize class instance), the size of the margins, and the orientation of the paper. Use the proper accessor methods to get the values. To get the metrics of the usable area of a paper (page without the margins) one can also use the PaperStyle.get_usable_width and PaperStyle.get_usable_height convenience methods. Width and height are always given according to the orientation of the paper, thus width is always the horizontal, and height is always the vertical dimension.

Text reports do not need to care about paper properties, as the document generator (or the external viewer) paginates the report according to those properties. While, on the other hand, graphical reports do need to take paper properties into account when creating graphical elements, i.e. they should not draw on the margins.

The origin of the coordinate system is the top left corner of the usable area.

Text document API

Draw document API

Graph document API