function test() { $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $style = 'background:url(/intl/en_com/images/logo_plain.png) no-repeat;height:110px;width:276px'; $css_processor =& new CSSProcessor(); $css_processor->set_pipeline($pipeline); $property_collection = $css_processor->import_source_ruleset($style, $pipeline->get_base_url()); $this->assertEquals(count($property_collection->_properties), 3); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.class.case.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $this->assertEquals(array(SELECTOR_ID, 'quickSummary'), $rule->selector[1][0]); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.margin.left.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $margin = $rule->body->_properties[0]->_value; $this->assertEquals(UNIT_PX, $margin->_units->_unit); $this->assertEquals(600, $margin->_units->_number); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.7.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $this->assertEquals(count($rule->body->_properties), 1); $property = $rule->body->_properties[0]; $this->assertEquals($property->_code, CSS_BACKGROUND); $this->assertEquals($property->_value->_image->_url, 'http://localhost/intl/en_com/images/logo_plain.png'); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.8.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $this->assertEquals(count($rule->body->_properties), 1); $property = $rule->body->_properties[0]; $this->assertEquals($property->_code, CSS_BACKGROUND_COLOR); $this->assertEquals($property->_value->r, 1); $this->assertEquals($property->_value->g, 1); $this->assertEquals($property->_value->b, 1); $this->assertEquals($property->_value->transparent, false); }
function test() { $tree = TreeBuilder::build(file_get_contents(dirname(__FILE__) . '/test.process.padding.html')); $pipeline = new Pipeline(); $pipeline->configure(array('renderimages' => true)); $pipeline->scan_styles($tree); $css = $pipeline->get_current_css(); $this->assertEquals(count($css->rules), 1); $rule = $css->rules[0]; $padding = $rule->body->_properties[1]->_value; $this->assertEquals(UNIT_PX, $padding->top->_units->_unit); $this->assertEquals(0, $padding->top->_units->_number); $this->assertEquals(UNIT_PX, $padding->right->_units->_unit); $this->assertEquals(175, $padding->right->_units->_number); $this->assertEquals(UNIT_PX, $padding->bottom->_units->_unit); $this->assertEquals(0, $padding->bottom->_units->_number); $this->assertEquals(UNIT_PX, $padding->left->_units->_unit); $this->assertEquals(110, $padding->left->_units->_number); }
die("Please specify non-zero value for the pixel width!"); } // 110723, dwildt + if ($this->b_drs_perform) { $endTime = $this->TT->getDifferenceToStarttime(); t3lib_div::devLog('[INFO/PERFORMANCE] html2ps is starting the process: ' . ($endTime - $this->startTime) . ' ms', $this->extKey, 0); } // 110723, dwildt + // begin processing $g_media = Media::predefined($GLOBALS['g_config']['media']); $g_media->set_landscape($GLOBALS['g_config']['landscape']); $g_media->set_margins($GLOBALS['g_config']['margins']); $g_media->set_pixels($GLOBALS['g_config']['pagewidth']); // Initialize the coversion pipeline $pipeline = new Pipeline(); $pipeline->configure($GLOBALS['g_config']); // Configure the fetchers if (extension_loaded('curl')) { require_once HTML2PS_DIR . 'fetcher.url.curl.class.php'; $pipeline->fetchers = array(new FetcherUrlCurl()); if ($proxy != '') { $pipeline->fetchers[0]->set_proxy($proxy); } } else { require_once HTML2PS_DIR . 'fetcher.url.class.php'; $pipeline->fetchers[] = new FetcherURL(); } // Configure the data filters $pipeline->data_filters[] = new DataFilterDoctype(); $pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']); if ($GLOBALS['g_config']['html2xhtml']) {
parse_config_file(dirname(__FILE__) . '/../html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => true, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); require_once dirname(__FILE__) . '/../config.inc.php'; require_once HTML2PS_DIR . 'pipeline.class.php'; require_once HTML2PS_DIR . 'fetcher.url.class.php'; parse_config_file(HTML2PS_DIR . 'html2ps.config'); $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false); $media = Media::predefined('A4'); $media->set_landscape(false); $media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0)); $media->set_pixels(1024); $g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels; $g_pt_scale = $g_px_scale * 1.43; foreach ($urls as $url) { $url_file = str_replace('http://', '', $url); $url_file = str_replace(':', '_', $url_file); $url_file = str_replace('/', '_', $url_file); $url_file = str_replace('.', '_', $url_file); $pipeline = new Pipeline(); $pipeline->configure($g_config); $pipeline->fetchers[] = new FetcherURL(); $pipeline->data_filters[] = new DataFilterHTML2XHTML(); $pipeline->parser = new ParserXHTML(); $pipeline->layout_engine = new LayoutEngineDefault(); $pipeline->output_driver = new OutputDriverFPDF($media); $pipeline->destination = new DestinationFile($url_file); if (!file_exists(dirname(__FILE__) . '/../out/' . $url_file . '.pdf')) { print $url . "\n"; $pipeline->process($url, $media); } }