예제 #1
0
 function &_layout_item($data_id, &$media, $offset, &$context, &$postponed_filter)
 {
     $this->_reset_page_at_rules();
     $css_cache = CSSCache::get();
     $this->_defaultCSS = $css_cache->compile("resource://default.css", file_get_contents(HTML2PS_DIR . '/default.css'));
     $this->_css = array();
     $this->pushCSS();
     $this->_cssState = array(new CSSState(CSS::get()));
     $font = $this->_cssState[0]->getProperty(CSS_FONT);
     $font->units2pt(0);
     $this->_cssState[0]->setProperty(CSS_FONT, $font);
     $data = $this->fetch($data_id);
     if (is_null($data)) {
         $dummy = null;
         return $dummy;
     }
     // Run raw data filters
     for ($i = 0; $i < count($this->data_filters); $i++) {
         $data = $this->data_filters[$i]->process($data);
     }
     // Parse the raw data
     $box =& $this->parser->process($data->get_content(), $this);
     /**
      * Run obligatory tree filters
      */
     /**
      * height-constraint processing filter;
      */
     $filter = new PreTreeFilterHeightConstraint();
     $filter->process($box, $data, $this);
     /**
      * Footnote support filter
      */
     $filter = new PreTreeFilterFootnotes();
     $filter->process($box, $data, $this);
     // Run pre-layout tree filters
     for ($i = 0, $size = count($this->pre_tree_filters); $i < $size; $i++) {
         $this->pre_tree_filters[$i]->process($box, $data, $this);
     }
     /**
      * Auto-detect top/bottom margin size (only if both top and bottom margins have zero value)
      */
     if ($media->margins['top'] == 0 && $media->margins['bottom'] == 0) {
         $boxes = $this->reflow_margin_boxes(0, $media);
         $media->margins['top'] = max($boxes[CSS_MARGIN_BOX_SELECTOR_TOP]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT_CORNER]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_CENTER]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT_CORNER]->get_real_full_height()) / mm2pt(1);
         $media->margins['bottom'] = max($boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT_CORNER]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_CENTER]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT]->get_real_full_height(), $boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT_CORNER]->get_real_full_height()) / mm2pt(1);
         $this->output_driver->update_media($media);
     }
     $context = new FlowContext();
     /**
      * Extract absolute/fixed positioned boxes
      */
     $positioned_filter = new PostTreeFilterPositioned($context);
     $positioned_filter->process($box, null, $this);
     $postponed_filter = new PostTreeFilterPostponed($this->output_driver);
     $postponed_filter->process($box, null, $this);
     $this->output_driver->prepare();
     $status = $this->layout_engine->process($box, $media, $this->output_driver, $context);
     if (is_null($status)) {
         error_log("Pipeline::_process_item: layout routine failed");
         $dummy = null;
         return $dummy;
     }
     // Run post-layout tree filters
     for ($i = 0; $i < count($this->post_tree_filters); $i++) {
         $this->post_tree_filters[$i]->process($box);
     }
     return $box;
 }
예제 #2
0
 function reset_css()
 {
     $css_cache = CSSCache::get();
     $this->_defaultCSS = $css_cache->compile('resource://default.css', file_get_contents(HTML2PS_DIR . 'default.css'), $this);
     $this->_css = array();
     $this->push_css();
     $this->_cssState = array(new CSSState(CSS::get()));
 }
 function &_layout_item($data_id, &$media, $offset, &$context, &$postponed_filter)
 {
     //echo 'start:'.microtime().'<br>';
     $this->_reset_page_at_rules();
     $css_cache = CSSCache::get();
     $this->_defaultCSS = $css_cache->compile('resource://default.css', file_get_contents(HTML2PS_DIR . '/default.css'));
     $this->_css = array();
     $this->pushCSS();
     $this->_cssState = array(new CSSState(CSS::get()));
     $font = $this->_cssState[0]->getProperty(CSS_FONT);
     $font->units2pt(0);
     $this->_cssState[0]->setProperty(CSS_FONT, $font);
     $data = $this->fetch($data_id);
     if (is_null($data)) {
         return null;
     }
     // Run raw data filters
     for ($i = 0; $i < count($this->data_filters); $i++) {
         $data = $this->data_filters[$i]->process($data);
     }
     // Parse the raw data
     # kornev, optimize
     //echo '001:'.microtime().'<br>';
     $box =& $this->parser->process($data->get_content(), $this, $media);
     $this->_dispatcher->fire('after-parse', array('pipeline' => &$this, 'document' => &$box, 'media' => $media));
     //echo '002:'.microtime().'<br>';
     /**
      * height-constraint processing filter;
      */
     $filter = new PreTreeFilterHeightConstraint();
     $filter->process($box, $data, $this);
     /**
      * Footnote support filter
      */
     $filter = new PreTreeFilterFootnotes();
     $filter->process($box, $data, $this);
     // Run pre-layout tree filters
     for ($i = 0, $size = count($this->pre_tree_filters); $i < $size; $i++) {
         $this->pre_tree_filters[$i]->process($box, $data, $this);
     }
     $context = new FlowContext();
     /**
      * Extract absolute/fixed positioned boxes
      */
     $positioned_filter = new PostTreeFilterPositioned($context);
     $positioned_filter->process($box, null, $this);
     $postponed_filter = new PostTreeFilterPostponed($this->output_driver);
     $postponed_filter->process($box, null, $this);
     $this->output_driver->prepare();
     //echo 'start creations'.microtime().'<br>';
     # kornev, optimize
     $status = $this->layout_engine->process($box, $media, $this->output_driver, $context);
     //echo 'end creations'.microtime().'<br>';
     if (is_null($status)) {
         error_log('Pipeline::_process_item: layout routine failed');
         $dummy = null;
         return $dummy;
     }
     // Run post-layout tree filters
     for ($i = 0; $i < count($this->post_tree_filters); $i++) {
         $this->post_tree_filters[$i]->process($box);
     }
     return $box;
 }