本文整理汇总了PHP中Frame_Factory::decorate_root方法的典型用法代码示例。如果您正苦于以下问题:PHP Frame_Factory::decorate_root方法的具体用法?PHP Frame_Factory::decorate_root怎么用?PHP Frame_Factory::decorate_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame_Factory
的用法示例。
在下文中一共展示了Frame_Factory::decorate_root方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders the HTML to PDF
*/
function render()
{
$this->save_locale();
$log_output_file = $this->get_option("log_output_file");
if ($log_output_file) {
if (!file_exists($log_output_file) && is_writable(dirname($log_output_file))) {
touch($log_output_file);
}
$this->_start_time = microtime(true);
ob_start();
}
//enable_mem_profile();
$this->_process_html();
$this->_css->apply_styles($this->_tree);
// @page style rules : size, margins
$page_styles = $this->_css->get_page_styles();
$base_page_style = $page_styles["base"];
unset($page_styles["base"]);
foreach ($page_styles as $_page_style) {
$_page_style->inherit($base_page_style);
}
if (is_array($base_page_style->size)) {
$this->set_paper(array(0, 0, $base_page_style->size[0], $base_page_style->size[1]));
}
$this->_pdf = Canvas_Factory::get_instance($this, $this->_paper_size, $this->_paper_orientation);
Font_Metrics::init($this->_pdf);
if ($this->get_option("enable_font_subsetting") && $this->_pdf instanceof CPDF_Adapter) {
foreach ($this->_tree->get_frames() as $frame) {
$style = $frame->get_style();
$node = $frame->get_node();
// Handle text nodes
if ($node->nodeName === "#text") {
$this->_pdf->register_string_subset($style->font_family, $node->nodeValue);
continue;
}
// Handle generated content (list items)
if ($style->display === "list-item") {
$chars = List_Bullet_Renderer::get_counter_chars($style->list_style_type);
$this->_pdf->register_string_subset($style->font_family, $chars);
continue;
}
// Handle other generated content (pseudo elements)
// FIXME: This only captures the text of the stylesheet declaration,
// not the actual generated content, and forces all possible counter
// values. See notes in issue #750.
if ($frame->get_node()->nodeName == "dompdf_generated") {
// all possible counter values
$chars = List_Bullet_Renderer::get_counter_chars('decimal');
$this->_pdf->register_string_subset($style->font_family, $chars);
$chars = List_Bullet_Renderer::get_counter_chars('upper-alpha');
$this->_pdf->register_string_subset($style->font_family, $chars);
$chars = List_Bullet_Renderer::get_counter_chars('lower-alpha');
$this->_pdf->register_string_subset($style->font_family, $chars);
$chars = List_Bullet_Renderer::get_counter_chars('lower-greek');
$this->_pdf->register_string_subset($style->font_family, $chars);
// the text of the stylesheet declaration
$this->_pdf->register_string_subset($style->font_family, $style->content);
continue;
}
}
}
$root = null;
foreach ($this->_tree->get_frames() as $frame) {
// Set up the root frame
if (is_null($root)) {
$root = Frame_Factory::decorate_root($this->_tree->get_root(), $this);
continue;
}
// Create the appropriate decorators, reflowers & positioners.
Frame_Factory::decorate_frame($frame, $this, $root);
}
// Add meta information
$title = $this->_xml->getElementsByTagName("title");
if ($title->length) {
$this->_pdf->add_info("Title", trim($title->item(0)->nodeValue));
}
$metas = $this->_xml->getElementsByTagName("meta");
$labels = array("author" => "Author", "keywords" => "Keywords", "description" => "Subject");
foreach ($metas as $meta) {
$name = mb_strtolower($meta->getAttribute("name"));
$value = trim($meta->getAttribute("content"));
if (isset($labels[$name])) {
$this->_pdf->add_info($labels[$name], $value);
continue;
}
if ($name === "dompdf.view" && $this->parse_default_view($value)) {
$this->_pdf->set_default_view($this->_default_view, $this->_default_view_options);
}
}
$root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
$root->set_renderer(new Renderer($this));
// This is where the magic happens:
$root->reflow();
// Clean up cached images
Image_Cache::clear();
global $_dompdf_warnings, $_dompdf_show_warnings;
if ($_dompdf_show_warnings) {
//.........这里部分代码省略.........
示例2: render
/**
* Renders the HTML to PDF
*/
function render()
{
$this->save_locale();
if (DOMPDF_LOG_OUTPUT_FILE) {
if (!file_exists(DOMPDF_LOG_OUTPUT_FILE) && is_writable(dirname(DOMPDF_LOG_OUTPUT_FILE))) {
touch(DOMPDF_LOG_OUTPUT_FILE);
}
$this->_start_time = microtime(true);
ob_start();
}
//enable_mem_profile();
$this->_process_html();
$this->_css->apply_styles($this->_tree);
$root = null;
foreach ($this->_tree->get_frames() as $frame) {
// Set up the root frame
if (is_null($root)) {
$root = Frame_Factory::decorate_root($this->_tree->get_root(), $this);
continue;
}
// Create the appropriate decorators, reflowers & positioners.
$deco = Frame_Factory::decorate_frame($frame, $this);
$deco->set_root($root);
// FIXME: handle generated content
if ($frame->get_style()->display === "list-item") {
// Insert a list-bullet frame
$node = $this->_xml->createElement("bullet");
// arbitrary choice
$b_f = new Frame($node);
$parent_node = $frame->get_parent()->get_node();
if (!$parent_node->hasAttribute("dompdf-children-count")) {
$count = 0;
foreach ($parent_node->childNodes as $_node) {
if ($_node instanceof DOMElement) {
$count++;
}
}
$parent_node->setAttribute("dompdf-children-count", $count);
}
$index = 0;
if (!$parent_node->hasAttribute("dompdf-counter")) {
$index = 1;
$parent_node->setAttribute("dompdf-counter", 1);
} else {
$index = $parent_node->getAttribute("dompdf-counter");
$index++;
$parent_node->setAttribute("dompdf-counter", $index);
}
$node->setAttribute("dompdf-counter", $index);
$style = $this->_css->create_style();
$style->display = "-dompdf-list-bullet";
$style->inherit($frame->get_style());
$b_f->set_style($style);
$deco->prepend_child(Frame_Factory::decorate_frame($b_f, $this));
}
}
$page_styles = $this->_css->get_page_styles();
$base_page_style = $page_styles["base"];
unset($page_styles["base"]);
foreach ($page_styles as $_page_style) {
$_page_style->inherit($base_page_style);
}
if (is_array($base_page_style->size)) {
$this->set_paper(array(0, 0, $base_page_style->size[0], $base_page_style->size[1]));
}
$this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_paper_orientation);
// Add meta information
$title = $this->_xml->getElementsByTagName("title");
if ($title->length) {
$this->_pdf->add_info("Title", trim($title->item(0)->nodeValue));
}
$metas = $this->_xml->getElementsByTagName("meta");
$labels = array("author" => "Author", "keywords" => "Keywords", "description" => "Subject");
foreach ($metas as $meta) {
$name = mb_strtolower($meta->getAttribute("name"));
$value = trim($meta->getAttribute("content"));
if (isset($labels[$name])) {
$this->_pdf->add_info($labels[$name], $value);
continue;
}
if ($name === "dompdf.view" && $this->parse_default_view($value)) {
$this->_pdf->set_default_view($this->_default_view, $this->_default_view_options);
}
}
$root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
$root->set_renderer(new Renderer($this));
// This is where the magic happens:
$root->reflow();
// Clean up cached images
Image_Cache::clear();
global $_dompdf_warnings, $_dompdf_show_warnings;
if ($_dompdf_show_warnings) {
echo '<b>DOMPDF Warnings</b><br><pre>';
foreach ($_dompdf_warnings as $msg) {
echo $msg . "\n";
}
echo $this->get_canvas()->get_cpdf()->messages;
//.........这里部分代码省略.........
示例3: render
/**
* Renders the HTML to PDF
*/
function render()
{
$this->_process_html();
$this->_css->apply_styles($this->_tree);
$root = null;
foreach ($this->_tree->get_frames() as $frame) {
// Set up the root frame
if (is_null($root)) {
$root = Frame_Factory::decorate_root($this->_tree->get_root());
continue;
}
// Create the appropriate decorators, reflowers & positioners.
$deco = Frame_Factory::decorate_frame($frame, $this);
$deco->set_root($root);
// FIXME: handle generated content
if ($frame->get_style()->display == "list-item" && in_array($frame->get_style()->list_style_type, List_Bullet_Frame_Decorator::$BULLET_TYPES)) {
// Insert a list-bullet frame
$node = $this->_xml->createElement("bullet");
// arbitrary choice
$b_f = new Frame($node);
$style = $this->_css->create_style();
$style->display = "-dompdf-list-bullet";
$style->inherit($frame->get_style());
$b_f->set_style($style);
$deco->prepend_child(Frame_Factory::decorate_frame($b_f));
}
}
$this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_orientation);
$root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
// This is where the magic happens:
$root->reflow();
$renderer = new Renderer($this->_pdf);
$renderer->render($root);
}
示例4: render
/**
* Renders the HTML to PDF
*/
function render()
{
//enable_mem_profile();
$this->_process_html();
$this->_css->apply_styles($this->_tree);
$root = null;
foreach ($this->_tree->get_frames() as $frame) {
// Set up the root frame
if (is_null($root)) {
$root = Frame_Factory::decorate_root($this->_tree->get_root(), $this);
continue;
}
// Create the appropriate decorators, reflowers & positioners.
$deco = Frame_Factory::decorate_frame($frame, $this);
$deco->set_root($root);
// FIXME: handle generated content
if ($frame->get_style()->display === "list-item") {
// Insert a list-bullet frame
$node = $this->_xml->createElement("bullet");
// arbitrary choice
$b_f = new Frame($node);
$style = $this->_css->create_style();
$style->display = "-dompdf-list-bullet";
$style->inherit($frame->get_style());
$b_f->set_style($style);
$deco->prepend_child(Frame_Factory::decorate_frame($b_f, $this));
}
}
$this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_paper_orientation);
$root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
$root->set_renderer(new Renderer($this));
// This is where the magic happens:
$root->reflow();
// Clean up cached images
Image_Cache::clear();
global $_dompdf_warnings, $_dompdf_show_warnings;
if ($_dompdf_show_warnings) {
echo '<b>DOMPDF Warnings</b><br><pre>';
foreach ($_dompdf_warnings as $msg) {
echo $msg . "\n";
}
echo $this->get_canvas()->get_cpdf()->messages;
echo '</pre>';
flush();
}
}
示例5: render
function render()
{
$this->save_locale();
if (DOMPDF_LOG_OUTPUT_FILE) {
if (!file_exists(DOMPDF_LOG_OUTPUT_FILE) && is_writable(dirname(DOMPDF_LOG_OUTPUT_FILE))) {
touch(DOMPDF_LOG_OUTPUT_FILE);
}
$this->_start_time = microtime(true);
ob_start();
}
$this->_process_html();
$this->_css->apply_styles($this->_tree);
$page_styles = $this->_css->get_page_styles();
$base_page_style = $page_styles["base"];
unset($page_styles["base"]);
foreach ($page_styles as $_page_style) {
$_page_style->inherit($base_page_style);
}
if (is_array($base_page_style->size)) {
$this->set_paper(array(0, 0, $base_page_style->size[0], $base_page_style->size[1]));
}
$this->_pdf = Canvas_Factory::get_instance($this->_paper_size, $this->_paper_orientation);
Font_Metrics::init($this->_pdf);
if (DOMPDF_ENABLE_FONTSUBSETTING && $this->_pdf instanceof CPDF_Adapter) {
foreach ($this->_tree->get_frames() as $frame) {
$style = $frame->get_style();
$node = $frame->get_node();
if ($node->nodeName === "#text") {
$this->_pdf->register_string_subset($style->font_family, $node->nodeValue);
continue;
}
if ($style->display === "list-item") {
$chars = List_Bullet_Renderer::get_counter_chars($style->list_style_type);
$this->_pdf->register_string_subset($style->font_family, $chars);
continue;
}
}
}
$root = null;
foreach ($this->_tree->get_frames() as $frame) {
if (is_null($root)) {
$root = Frame_Factory::decorate_root($this->_tree->get_root(), $this);
continue;
}
$deco = Frame_Factory::decorate_frame($frame, $this);
$deco->set_root($root);
if ($frame->get_style()->display === "list-item") {
$node = $this->_xml->createElement("bullet");
$b_f = new Frame($node);
$parent_node = $frame->get_parent()->get_node();
if (!$parent_node->hasAttribute("dompdf-children-count")) {
$xpath = new DOMXPath($this->_xml);
$count = $xpath->query("li", $parent_node)->length;
$parent_node->setAttribute("dompdf-children-count", $count);
}
if (!$parent_node->hasAttribute("dompdf-counter")) {
$index = $parent_node->hasAttribute("start") ? $parent_node->getAttribute("start") - 1 : 0;
} else {
$index = $parent_node->getAttribute("dompdf-counter");
}
$index++;
$parent_node->setAttribute("dompdf-counter", $index);
$node->setAttribute("dompdf-counter", $index);
$style = $this->_css->create_style();
$style->display = "-dompdf-list-bullet";
$style->inherit($frame->get_style());
$b_f->set_style($style);
$deco->prepend_child(Frame_Factory::decorate_frame($b_f, $this));
}
}
$title = $this->_xml->getElementsByTagName("title");
if ($title->length) {
$this->_pdf->add_info("Title", trim($title->item(0)->nodeValue));
}
$metas = $this->_xml->getElementsByTagName("meta");
$labels = array("author" => "Author", "keywords" => "Keywords", "description" => "Subject");
foreach ($metas as $meta) {
$name = mb_strtolower($meta->getAttribute("name"));
$value = trim($meta->getAttribute("content"));
if (isset($labels[$name])) {
$this->_pdf->add_info($labels[$name], $value);
continue;
}
if ($name === "dompdf.view" && $this->parse_default_view($value)) {
$this->_pdf->set_default_view($this->_default_view, $this->_default_view_options);
}
}
$root->set_containing_block(0, 0, $this->_pdf->get_width(), $this->_pdf->get_height());
$root->set_renderer(new Renderer($this));
$root->reflow();
Image_Cache::clear();
global $_dompdf_warnings, $_dompdf_show_warnings;
if ($_dompdf_show_warnings) {
echo '<b>DOMPDF Warnings</b><br><pre>';
foreach ($_dompdf_warnings as $msg) {
echo $msg . "\n";
}
echo $this->get_canvas()->get_cpdf()->messages;
echo '</pre>';
flush();
//.........这里部分代码省略.........
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:101,代码来源:dompdf.cls.php