def render_to_cairo_document(output_filename, papersize_tuple, layout):
    """Create and save a document with contents of the given layout manager."""
    doc = cairo.PDFSurface(output_filename, *papersize_tuple)
    c = cairo.Context(doc)
    render_to_cairo_context(c, papersize_tuple, layout)
Create and save a document with contents of the given layout manager.