2.5.1. Reportlab Wrappers (layout.rl_utils
)¶
This module provides helper functions to render managers to one or
more pages of a reportlab canvas. To create multi-page documents, use
the layout.pages.output.PagesLM
class to wrap a series of
single-page managers.
-
class
layout.rl_utils.
PDFImage
(filename)¶ Bases:
layout.managers.root.LayoutElement
A PDF file to be displayed at a fixed aspect ratio.
-
get_minimum_size
(data)¶ How small can the element be? Should return a Point.
-
render
(rectangle, data)¶ Asks the element to render itself.
-
-
class
layout.rl_utils.
ReportlabOutput
(rl_canvas)¶ Bases:
layout.datatypes.output.OutputTarget
An output adapter for ReportLab.
-
clip_rect
(x, y, w, h)¶ Clip further output to this rect.
-
draw_image
(img_filename, x, y, w, h)¶ Draws the given image.
-
draw_line
(x0, y0, x1, y1, *, stroke, stroke_width=1, stroke_dash=None)¶ Draws the given line.
-
draw_polygon
(*pts, close_path=True, stroke=None, stroke_width=1, stroke_dash=None, fill=None) → None¶ Draws the given polygon.
-
draw_rect
(x, y, w, h, *, stroke=None, stroke_width=1, stroke_dash=None, fill=None) → None¶ Draws the given rectangle.
-
draw_text
(text, x, y, *, font_name, font_size, fill)¶ Draws the given text at x,y.
-
end_page
()¶ Complete the previous page and prepare to begin a new page.
-
rotate
(degrees)¶ Rotate the current rendering context.
-
scale
(x, y)¶ Scale the current rendering context.
-
text_width
(text, *, font_name, font_size)¶ The width of the given text string.
-
translate
(x, y)¶ Translate the current rendering context.
-
-
layout.rl_utils.
render_to_reportlab_canvas
(rl_canvas, papersize_tuple, layout)¶ Renders the given layout manager on a page of the given canvas.
-
layout.rl_utils.
render_to_reportlab_document
(output_filename, papersize_tuple, layout)¶ Create and save a document with contents of the given layout manager.