1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 08:27:22 +03:00
WeasyPrint/weasyprint/layout/__init__.py

39 lines
1.0 KiB
Python

# coding: utf8
"""
weasyprint.layout
-----------------
Transform a "before layout" box tree into an "after layout" tree.
(Surprising, hu?)
Break boxes across lines and pages; determine the size and dimension
of each box fragement.
Boxes in the new tree have *used values* in their ``position_x``,
``position_y``, ``width`` and ``height`` attributes, amongst others.
See http://www.w3.org/TR/CSS21/cascade.html#used-value
:copyright: Copyright 2011-2012 Simon Sapin and contributors, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import division, unicode_literals
from .pages import make_all_pages, add_margin_boxes
def layout_document(document, root_box):
"""Lay out the whole document.
This includes line breaks, page breaks, absolute size and position for all
boxes.
:param document: a Document object.
:returns: a list of laid out Page objects.
"""
pages = list(make_all_pages(document, root_box))
return list(add_margin_boxes(document, pages))