Document (rinoh.document)

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

Holds the document’s contents as a tree of flowables

Parameters:
flowables : list[Flowable]

the list of top-level flowables

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

user-defined string variables and can override localized strings provided by language

backend=None

the backend used for rendering the document

number_of_pages(part_name)

The number of pages in a document part (previous rendering pass)

element_style(element)

Return the ElementStyle for element

These are stored in element_styles by the id of element. Entries are removed when element is garbage collected, so that its id can’t be mistaken for that of a new element.

get_computed_style(styled)

Return the ComputedStyle for styled

get_style_value(styled, attribute)

Return the value of the style attribute for styled

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.

Pages

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

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

display_sideways : Sideways

display the page rotated

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

Write this container’s contents onto the page’s canvas

The contents are written directly to page_canvas instead of to the parent container’s canvas, so that they are copied only once.

Parameters:
page_canvas : Canvas

the canvas of the page

offsets : tuple

the (left, top) positions of the containers this container is placed in relative to their parent, innermost first

class rinoh.document.PageOrientation

Accepts: portrait, landscape

class rinoh.document.PageType

Accepts: left, right, any

class rinoh.document.PageNumberFormat

How (or if) page numbers are displayed

Accepts: none, number, symbol, lowercase character, uppercase character, lowercase roman, uppercase roman, continue