Document (rinoh.document)

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

Holds the document’s contents as a tree of flowables

Parameters
  • 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

Parameters
  • 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_outlines()

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.

Pages

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.

Parameters
  • 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()

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()

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