Document (rinoh.document)

class rinoh.document.DocumentTree(flowables, source_file=None, options=None)

Holds the document’s contents as a tree of flowables

  • flowables (list[Flowable]) – the list of top-level flowables

  • source_file (Path) – absolute path of the source file, used to locate images and include in logging and error and warnings.

  • options (Reader) – frontend-specific options

class rinoh.document.Document(document_tree, stylesheet, language, strings=None, backend=None)

Renders a document tree to pages

  • document_tree (DocumentTree) – a tree of the document’s contents

  • stylesheet (StyleSheet) – style sheet used to style document elements

  • language (Language) – the language to use for standard strings

  • strings (Strings) – overrides localized strings provided by language

  • backend – the backend used for rendering the document

render(filename_root=None, file=None)

Render the document repeatedly until the output no longer changes due to cross-references that need some iterations to converge.


Create an outline in the output file that allows for easy navigation of the document. The outline is a hierarchical tree of all the sections in the document.


class rinoh.document.Page(document_part, number, paper, orientation='portrait')

A single page in a document.

A Page is a Container, so other containers can be added as children.

  • document_part (DocumentPart) – the document part this page is part of

  • number (int) – the 1-based index of this page in the document part

  • paper (Paper) – determines the dimensions of this page

  • orientation (PageOrientation) – the orientation of this page

property page

Returns the page itself.


Render the contents of this container to its canvas.

Note that the rendered contents need to be place()d on the parent container’s canvas before they become visible.


Place this container’s canvas onto the parent container’s canvas.

class rinoh.document.PageOrientation

Accepts: portrait, landscape

class rinoh.document.PageType

Accepts: left, right, any