1 | <?php |
---|
2 | /** |
---|
3 | * DOMPDF - PHP5 HTML to PDF renderer |
---|
4 | * |
---|
5 | * File: $RCSfile: page_frame_reflower.cls.php,v $ |
---|
6 | * Created on: 2004-06-16 |
---|
7 | * |
---|
8 | * Copyright (c) 2004 - Benj Carson <benjcarson@digitaljunkies.ca> |
---|
9 | * |
---|
10 | * This library is free software; you can redistribute it and/or |
---|
11 | * modify it under the terms of the GNU Lesser General Public |
---|
12 | * License as published by the Free Software Foundation; either |
---|
13 | * version 2.1 of the License, or (at your option) any later version. |
---|
14 | * |
---|
15 | * This library is distributed in the hope that it will be useful, |
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | * Lesser General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU Lesser General Public License |
---|
21 | * along with this library in the file LICENSE.LGPL; if not, write to the |
---|
22 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
---|
23 | * 02111-1307 USA |
---|
24 | * |
---|
25 | * Alternatively, you may distribute this software under the terms of the |
---|
26 | * PHP License, version 3.0 or later. A copy of this license should have |
---|
27 | * been distributed with this file in the file LICENSE.PHP . If this is not |
---|
28 | * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
---|
29 | * |
---|
30 | * The latest version of DOMPDF might be available at: |
---|
31 | * http://www.digitaljunkies.ca/dompdf |
---|
32 | * |
---|
33 | * @link http://www.digitaljunkies.ca/dompdf |
---|
34 | * @copyright 2004 Benj Carson |
---|
35 | * @author Benj Carson <benjcarson@digitaljunkies.ca> |
---|
36 | * @package dompdf |
---|
37 | * @version 0.5.1 |
---|
38 | */ |
---|
39 | |
---|
40 | /* $Id: page_frame_reflower.cls.php,v 1.5 2006/07/07 21:31:04 benjcarson Exp $ */ |
---|
41 | |
---|
42 | /** |
---|
43 | * Reflows pages |
---|
44 | * |
---|
45 | * @access private |
---|
46 | * @package dompdf |
---|
47 | */ |
---|
48 | class Page_Frame_Reflower extends Frame_Reflower { |
---|
49 | |
---|
50 | |
---|
51 | function __construct(Page_Frame_Decorator $frame) { parent::__construct($frame); } |
---|
52 | |
---|
53 | //........................................................................ |
---|
54 | |
---|
55 | function reflow() { |
---|
56 | $style = $this->_frame->get_style(); |
---|
57 | |
---|
58 | // Paged layout: |
---|
59 | // http://www.w3.org/TR/CSS21/page.html |
---|
60 | |
---|
61 | // Pages are only concerned with margins |
---|
62 | $cb = $this->_frame->get_containing_block(); |
---|
63 | $left = $style->length_in_pt($style->margin_left, $cb["w"]); |
---|
64 | $right = $style->length_in_pt($style->margin_right, $cb["w"]); |
---|
65 | $top = $style->length_in_pt($style->margin_top, $cb["w"]); |
---|
66 | $bottom = $style->length_in_pt($style->margin_bottom, $cb["w"]); |
---|
67 | |
---|
68 | $content_x = $cb["x"] + $left; |
---|
69 | $content_y = $cb["y"] + $top; |
---|
70 | $content_width = $cb["w"] - $left - $right; |
---|
71 | $content_height = $cb["h"] - $top - $bottom; |
---|
72 | |
---|
73 | $child = $this->_frame->get_first_child(); |
---|
74 | |
---|
75 | while ($child) { |
---|
76 | |
---|
77 | $child->set_containing_block($content_x, $content_y, $content_width, $content_height); |
---|
78 | $child->reflow(); |
---|
79 | $next_child = $child->get_next_sibling(); |
---|
80 | |
---|
81 | // Render the page |
---|
82 | $this->_frame->get_renderer()->render($child); |
---|
83 | if ( $next_child ) |
---|
84 | $this->_frame->next_page(); |
---|
85 | |
---|
86 | // Dispose of all frames on the old page |
---|
87 | $child->dispose(true); |
---|
88 | |
---|
89 | $child = $next_child; |
---|
90 | } |
---|
91 | } |
---|
92 | } |
---|
93 | ?> |
---|