function render(Frame $frame) { $style = $frame->get_style(); list($x, $y, $w, $h) = $frame->get_padding_box(); $this->_set_opacity($frame->get_opacity($style->opacity)); // Draw our background, border and content if (($bg = $style->background_color) !== "transparent") { $this->_canvas->filled_rectangle($x, $y, $w, $h, $bg); } if (($url = $style->background_image) && $url !== "none") { $this->_background_image($url, $x, $y, $w, $h, $style); } $this->_render_border($frame); $this->_render_outline($frame); if (DEBUG_LAYOUT && DEBUG_LAYOUT_BLOCKS) { $this->_debug_layout($frame->get_border_box(), "red"); if (DEBUG_LAYOUT_PADDINGBOX) { $this->_debug_layout($frame->get_padding_box(), "red", array(0.5, 0.5)); } } if (DEBUG_LAYOUT && DEBUG_LAYOUT_LINES && $frame->get_decorator()) { foreach ($frame->get_decorator()->get_line_boxes() as $line) { $frame->_debug_layout(array($line->x, $line->y, $line->w, $line->h), "orange"); } } }
function render(Frame $frame) { $style = $frame->get_style(); list($x, $y, $w, $h) = $frame->get_padding_box(); // Draw our background, border and content if (($bg = $style->background_color) !== "transparent") { $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); } if (($url = $style->background_image) && $url !== "none") { $this->_background_image($url, $x, $y, $w, $h, $style); } $this->_render_border($frame); }
function render(Frame $frame) { // Render background & borders //parent::render($frame); $p = $frame->get_parent(); $style = $frame->get_style(); $cb = $frame->get_containing_block(); list($x, $y) = $frame->get_padding_box(); $x += $style->length_in_pt($style->padding_left, $cb["w"]); $y += $style->length_in_pt($style->padding_top, $cb["h"]); $w = $style->length_in_pt($style->width, $cb["w"]); $h = $style->length_in_pt($style->height, $cb["h"]); $this->_canvas->image($frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h); }
function render(Frame $frame) { $style = $frame->get_style(); // Draw our background, border and content if (($bg = $style->background_color) !== "transparent") { list($x, $y, $w, $h) = $frame->get_padding_box(); $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); } // FIXME: need to enable & test this eventually // if ( ($img = $style->background_image) !== "none" ) { // list($x, $y, $w, $h) = $frame->get_padding_box(); // list($bx, $by) = $style->background_position; // $bx = $style->length_in_pt($bx, $w); // $by = $style->length_in_pt($by, $h); // $this->_canvas->image($img, $x + $bx, $y + $by); // } $this->_render_border($frame); }
function get_padding_box() { return $this->_frame->get_padding_box(); }
/** * Render frames recursively * * @param Frame $frame the frame to render */ function render(Frame $frame) { global $_dompdf_debug; if ($_dompdf_debug) { echo $frame; flush(); } $style = $frame->get_style(); $display = $style->display; // Starts the CSS transformation if ($style->transform && is_array($style->transform)) { $this->_canvas->save(); list($x, $y, $w, $h) = $frame->get_padding_box(); $origin = $style->transform_origin; foreach ($style->transform as $transform) { list($function, $values) = $transform; if ($function === "matrix") { $function = "transform"; } $values = array_map("floatval", $values); $values[] = $x + $style->length_in_pt($origin[0], $style->width); $values[] = $y + $style->length_in_pt($origin[1], $style->height); call_user_func_array(array($this->_canvas, $function), $values); } } switch ($display) { case "block": case "list-item": case "inline-block": case "table": case "table-row-group": case "table-header-group": case "table-footer-group": case "inline-table": $this->_render_frame("block", $frame); break; case "inline": if ($frame->get_node()->nodeName === "#text") { $this->_render_frame("text", $frame); } else { $this->_render_frame("inline", $frame); } break; case "table-cell": $this->_render_frame("table-cell", $frame); break; case "-dompdf-list-bullet": $this->_render_frame("list-bullet", $frame); break; case "-dompdf-image": $this->_render_frame("image", $frame); break; case "none": $node = $frame->get_node(); if ($node->nodeName === "script") { if ($node->getAttribute("type") === "text/php" || $node->getAttribute("language") === "php") { // Evaluate embedded php scripts $this->_render_frame("php", $frame); } elseif ($node->getAttribute("type") === "text/javascript" || $node->getAttribute("language") === "javascript") { // Insert JavaScript $this->_render_frame("javascript", $frame); } } // Don't render children, so skip to next iter return; default: break; } // Check for begin frame callback $this->_check_callbacks("begin_frame", $frame); // Starts the overflow: hidden box if ($style->overflow === "hidden") { list($x, $y, $w, $h) = $frame->get_padding_box(); $this->_canvas->clipping_rectangle($x, $y, $w, $h); } $page = $frame->get_root()->get_reflower(); foreach ($frame->get_children() as $child) { $child_style = $child->get_style(); // Stacking context if ($child_style->z_index !== false && ($child_style->z_index !== "auto" || in_array($child_style->position, Style::$POSITIONNED_TYPES))) { $z_index = $child_style->z_index === "auto" ? 0 : intval($child_style->z_index); $page->add_frame_to_stacking_context($child, $z_index); $child_style->z_index = false; } else { $this->render($child); } } // Ends the overflow: hidden box if ($style->overflow === "hidden") { $this->_canvas->clipping_end(); } if ($style->transform && is_array($style->transform)) { $this->_canvas->restore(); } // Check for end frame callback $this->_check_callbacks("end_frame", $frame); }
/** * Render frames recursively * * @param Frame $frame the frame to render */ function render(Frame $frame) { global $_dompdf_debug; if ($_dompdf_debug) { echo $frame; flush(); } $style = $frame->get_style(); if (in_array($style->visibility, array("hidden", "collapse"))) { return; } $display = $style->display; // Starts the CSS transformation if ($style->transform && is_array($style->transform)) { $this->_canvas->save(); list($x, $y) = $frame->get_padding_box(); $origin = $style->transform_origin; foreach ($style->transform as $transform) { list($function, $values) = $transform; if ($function === "matrix") { $function = "transform"; } $values = array_map("floatval", $values); $values[] = $x + $style->length_in_pt($origin[0], $style->width); $values[] = $y + $style->length_in_pt($origin[1], $style->height); call_user_func_array(array($this->_canvas, $function), $values); } } switch ($display) { case "block": case "list-item": case "inline-block": case "table": case "inline-table": $this->_render_frame("block", $frame); break; case "inline": if ($frame->is_text_node()) { $this->_render_frame("text", $frame); } else { $this->_render_frame("inline", $frame); } break; case "table-cell": $this->_render_frame("table-cell", $frame); break; case "table-row-group": case "table-header-group": case "table-footer-group": $this->_render_frame("table-row-group", $frame); break; case "-dompdf-list-bullet": $this->_render_frame("list-bullet", $frame); break; case "-dompdf-image": $this->_render_frame("image", $frame); break; case "none": $node = $frame->get_node(); if ($node->nodeName === "script") { if ($node->getAttribute("type") === "text/php" || $node->getAttribute("language") === "php") { // Evaluate embedded php scripts $this->_render_frame("php", $frame); } elseif ($node->getAttribute("type") === "text/javascript" || $node->getAttribute("language") === "javascript") { // Insert JavaScript $this->_render_frame("javascript", $frame); } } // Don't render children, so skip to next iter return; default: break; } // Starts the overflow: hidden box if ($style->overflow === "hidden") { list($x, $y, $w, $h) = $frame->get_padding_box(); // get border radii $style = $frame->get_style(); list($tl, $tr, $br, $bl) = $style->get_computed_border_radius($w, $h); if ($tl + $tr + $br + $bl > 0) { $this->_canvas->clipping_roundrectangle($x, $y, $w, $h, $tl, $tr, $br, $bl); } else { $this->_canvas->clipping_rectangle($x, $y, $w, $h); } } $stack = array(); foreach ($frame->get_children() as $child) { // < 0 : nagative z-index // = 0 : no z-index, no stacking context // = 1 : stacking context without z-index // > 1 : z-index $child_style = $child->get_style(); $child_z_index = $child_style->z_index; $z_index = 0; if ($child_z_index !== "auto") { $z_index = intval($child_z_index) + 1; } elseif ($child_style->float !== "none" || $child->is_positionned()) { $z_index = 1; } $stack[$z_index][] = $child; } ksort($stack); foreach ($stack as $by_index) { foreach ($by_index as $child) { $this->render($child); } } // Ends the overflow: hidden box if ($style->overflow === "hidden") { $this->_canvas->clipping_end(); } if ($style->transform && is_array($style->transform)) { $this->_canvas->restore(); } // Check for end frame callback $this->_check_callbacks("end_frame", $frame); }
function render(Frame $frame) { $style = $frame->get_style(); list($x, $y, $w, $h) = $frame->get_padding_box(); // Draw our background, border and content if (($bg = $style->background_color) !== "transparent") { list($x, $y, $w, $h) = $frame->get_padding_box(); $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); } if (($url = $style->background_image) && $url !== "none") { $this->_background_image($url, $x, $y, $w, $h, $style); } if ($style->border_collapse !== "collapse") { $this->_render_border($frame, "bevel"); return; } // The collapsed case is slightly complicated... $cellmap = Table_Frame_Decorator::find_parent_table($frame)->get_cellmap(); $cells = $cellmap->get_spanned_cells($frame); $num_rows = $cellmap->get_num_rows(); $num_cols = $cellmap->get_num_cols(); // Determine the top row spanned by this cell $i = $cells["rows"][0]; $top_row = $cellmap->get_row($i); // Determine if this cell borders on the bottom of the table. If so, // then we draw its bottom border. Otherwise the next row down will // draw its top border instead. if (in_array($num_rows - 1, $cells["rows"])) { $draw_bottom = true; $bottom_row = $cellmap->get_row($num_rows - 1); } else { $draw_bottom = false; } // Draw the horizontal borders foreach ($cells["columns"] as $j) { $bp = $cellmap->get_border_properties($i, $j); $y = $top_row["y"] - $bp["top"]["width"] / 2; $col = $cellmap->get_column($j); $x = $col["x"] - $bp["left"]["width"] / 2; $w = $col["used-width"] + ($bp["left"]["width"] + $bp["right"]["width"]) / 2; if ($bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0) { $widths = array($bp["top"]["width"], $bp["right"]["width"], $bp["bottom"]["width"], $bp["left"]["width"]); $method = "_border_" . $bp["top"]["style"]; $this->{$method}($x, $y, $w, $bp["top"]["color"], $widths, "top", "square"); } if ($draw_bottom) { $bp = $cellmap->get_border_properties($num_rows - 1, $j); if ($bp["bottom"]["style"] === "none" || $bp["bottom"]["width"] <= 0) { continue; } $y = $bottom_row["y"] + $bottom_row["height"] + $bp["bottom"]["width"] / 2; $widths = array($bp["top"]["width"], $bp["right"]["width"], $bp["bottom"]["width"], $bp["left"]["width"]); $method = "_border_" . $bp["bottom"]["style"]; $this->{$method}($x, $y, $w, $bp["bottom"]["color"], $widths, "bottom", "square"); } } $j = $cells["columns"][0]; $left_col = $cellmap->get_column($j); if (in_array($num_cols - 1, $cells["columns"])) { $draw_right = true; $right_col = $cellmap->get_column($num_cols - 1); } else { $draw_right = false; } // Draw the vertical borders foreach ($cells["rows"] as $i) { $bp = $cellmap->get_border_properties($i, $j); $x = $left_col["x"] - $bp["left"]["width"] / 2; $row = $cellmap->get_row($i); $y = $row["y"] - $bp["top"]["width"] / 2; $h = $row["height"] + ($bp["top"]["width"] + $bp["bottom"]["width"]) / 2; if ($bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0) { $widths = array($bp["top"]["width"], $bp["right"]["width"], $bp["bottom"]["width"], $bp["left"]["width"]); $method = "_border_" . $bp["left"]["style"]; $this->{$method}($x, $y, $h, $bp["left"]["color"], $widths, "left", "square"); } if ($draw_right) { $bp = $cellmap->get_border_properties($i, $num_cols - 1); if ($bp["right"]["style"] === "none" || $bp["right"]["width"] <= 0) { continue; } $x = $right_col["x"] + $right_col["used-width"] + $bp["right"]["width"] / 2; $widths = array($bp["top"]["width"], $bp["right"]["width"], $bp["bottom"]["width"], $bp["left"]["width"]); $method = "_border_" . $bp["right"]["style"]; $this->{$method}($x, $y, $h, $bp["right"]["color"], $widths, "right", "square"); } } }
function render(Frame $frame, $stacking = false) { global $_dompdf_debug; if ($_dompdf_debug) { echo $frame; flush(); } $style = $frame->get_style(); if (in_array($style->visibility, array("hidden", "collapse"))) { return; } $render_self = self::$stacking_first_pass && !$stacking || !self::$stacking_first_pass; if ($render_self) { $display = $style->display; if ($style->transform && is_array($style->transform)) { $this->_canvas->save(); list($x, $y, $w, $h) = $frame->get_padding_box(); $origin = $style->transform_origin; foreach ($style->transform as $transform) { list($function, $values) = $transform; if ($function === "matrix") { $function = "transform"; } $values = array_map("floatval", $values); $values[] = $x + $style->length_in_pt($origin[0], $style->width); $values[] = $y + $style->length_in_pt($origin[1], $style->height); call_user_func_array(array($this->_canvas, $function), $values); } } switch ($display) { case "block": case "list-item": case "inline-block": case "table": case "inline-table": $this->_render_frame("block", $frame); break; case "inline": if ($frame->is_text_node()) { $this->_render_frame("text", $frame); } else { $this->_render_frame("inline", $frame); } break; case "table-cell": $this->_render_frame("table-cell", $frame); break; case "table-row-group": case "table-header-group": case "table-footer-group": $this->_render_frame("table-row-group", $frame); break; case "-dompdf-list-bullet": $this->_render_frame("list-bullet", $frame); break; case "-dompdf-image": $this->_render_frame("image", $frame); break; case "none": $node = $frame->get_node(); if ($node->nodeName === "script") { if ($node->getAttribute("type") === "text/php" || $node->getAttribute("language") === "php") { $this->_render_frame("php", $frame); } elseif ($node->getAttribute("type") === "text/javascript" || $node->getAttribute("language") === "javascript") { $this->_render_frame("javascript", $frame); } } return; default: break; } $this->_check_callbacks("begin_frame", $frame); if ($style->overflow === "hidden") { list($x, $y, $w, $h) = $frame->get_padding_box(); $this->_canvas->clipping_rectangle($x, $y, $w, $h); } } $page = $frame->get_root()->get_reflower(); foreach ($frame->get_children() as $child) { $child_style = $child->get_style(); $_stacking = $stacking; if (self::$stacking_first_pass && ($child_style->z_index !== "auto" || $child_style->float !== "none" || $child->is_positionned())) { $z_index = $child_style->z_index === "auto" ? 0 : intval($child_style->z_index); $page->add_frame_to_stacking_context($child, $z_index); $_stacking = true; } $this->render($child, $_stacking); } if ($render_self) { if ($style->overflow === "hidden") { $this->_canvas->clipping_end(); } if ($style->transform && is_array($style->transform)) { $this->_canvas->restore(); } $this->_check_callbacks("end_frame", $frame); } }