当前位置: 首页>>代码示例>>PHP>>正文


PHP mm2pt函数代码示例

本文整理汇总了PHP中mm2pt函数的典型用法代码示例。如果您正苦于以下问题:PHP mm2pt函数的具体用法?PHP mm2pt怎么用?PHP mm2pt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mm2pt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPagebreakBorderTestNoBorder

    function testPagebreakBorderTestNoBorder()
    {
        $media = new Media(array('width' => 100, 'height' => 200 / mm2pt(1)), array('top' => 0, 'bottom' => 0, 'left' => 0, 'right' => 0));
        $tree = $this->runPipeline('
<html>
<head>
<style type="text/css">
body   { font-size: 10pt; line-height: 1; orphans:0; widows: 0; padding: 0; margin: 0; }
#first { line-height: 1; height: 180pt; }
#second { width: 3em; }
</style>
</head>
<body>
<div id="first">&nbsp;</div>
<div id="second">
LINE1<!--Page break should be here-->
LINE2
LINE3
LINE4
LINE5
</div>
</body>
</html>
', $media);
        /**
         * Calculate page heights
         */
        $page_heights = PageBreakLocator::getPages($tree, mm2pt($media->real_height()), mm2pt($media->height() - $media->margins['top']));
        $first_div = $tree->get_element_by_id('first');
        $second_div = $tree->get_element_by_id('second');
        $this->assertEqual(count($page_heights), 2, sprintf("Two pages expected, got %s", count($page_heights)));
        $this->assertEqual($page_heights[0], $first_div->get_full_height() + pt2pt(20));
    }
开发者ID:aedvalson,项目名称:Nexus,代码行数:33,代码来源:test.pagebreak.border.php

示例2: testPagebreakTable2

    function testPagebreakTable2()
    {
        $media = new Media(array('width' => 100, 'height' => 200 / mm2pt(1)), array('top' => 0, 'bottom' => 0, 'left' => 0, 'right' => 0));
        $tree = $this->runPipeline('
<html>
<head>
body   { font-size: 10pt; line-height: 1; padding: 0; margin: 0; }
table  { line-height: 1; }
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" id="table">
<tr><td id="cell">TEXT1_1<br/>TEXT1_2</td></tr>
</table>
</body>
</html>
', $media);
        $locations = PageBreakLocator::_getBreakLocations($tree);
        $table = $tree->get_element_by_id('table');
        $cell = $tree->get_element_by_id('cell');
        $line1 = $cell->content[0]->getLineBox(0);
        $this->assertEqual(count($locations), 3, "Testing number of page breaks inside a table with one cell & several text lines inside [%s]");
        $this->assertEqual($locations[0]->location, $table->get_top_margin(), "First page break should be at the table top [%s]");
        $this->assertEqual($locations[1]->location, $line1->bottom, "Second page break should be at the bottom of the first line box in the table cell [%s]");
        $this->assertEqual($locations[2]->location, $table->get_bottom_margin(), "Last page break should be at the table bottom [%s]");
    }
开发者ID:sharmarakesh,项目名称:EduSec2.0.0,代码行数:26,代码来源:test.pagebreak.table.php

示例3: init

 function init()
 {
     // Include the class file and create Html2ps instance
     App::import('vendor', 'Html2PsConfig', array('file' => 'html2ps' . DS . 'config.inc.php'));
     App::import('vendor', 'Html2Ps', array('file' => 'html2ps' . DS . 'pipeline.factory.class.php'));
     parse_config_file(APP . 'vendors' . DS . 'html2ps' . DS . 'html2ps.config');
     global $g_config;
     $g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false);
     $this->media = Media::predefined('A4');
     $this->media->set_landscape(false);
     $this->media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0));
     $this->media->set_pixels(1024);
     global $g_px_scale;
     $g_px_scale = mm2pt($this->media->width() - $this->media->margins['left'] - $this->media->margins['right']) / $this->media->pixels;
     global $g_pt_scale;
     $g_pt_scale = $g_pt_scale * 1.43;
     $this->p = PipelineFactory::create_default_pipeline("", "");
     switch ($this->output) {
         case 'download':
             $this->p->destination = new DestinationDownload($this->filename);
             break;
         case 'file':
             $this->p->destination = new DestinationFile($this->filename);
             break;
         default:
             $this->p->destination = new DestinationBrowser($this->filename);
             break;
     }
 }
开发者ID:raveebhat,项目名称:app,代码行数:29,代码来源:pdf.php

示例4: reflow

 function reflow(&$media)
 {
     $this->put_left(mm2pt($media->margins['left']));
     $this->put_top(mm2pt($media->height() - $media->margins['top']));
     $this->put_width(mm2pt($media->real_width()));
     $this->put_height(mm2pt($media->real_height()));
 }
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:7,代码来源:box.page.php

示例5: testWidthAbsolutePositioned1

 function testWidthAbsolutePositioned1()
 {
     $media = null;
     $pipeline = null;
     $tree = $this->runPipeline(file_get_contents('test.width.absolute.positioned.1.html'), $media, $pipeline);
     $font_size = $tree->getCSSProperty(CSS_FONT_SIZE);
     $base = $font_size->getPoints();
     $element =& $tree->get_element_by_id('div1');
     $this->assertWithinMargin($element->get_width(), $pipeline->output_driver->stringwidth('No positioning data at all', 'Times-Roman', 'iso-8859-1', $base), 0);
     $element =& $tree->get_element_by_id('div2');
     $this->assertWithinMargin($element->get_width(), $pipeline->output_driver->stringwidth('Left', 'Times-Roman', 'iso-8859-1', $base), 0);
     $element =& $tree->get_element_by_id('div3');
     $this->assertEqual($element->get_width(), mm2pt($media->real_width()) - px2pt(200));
     $element =& $tree->get_element_by_id('div4');
     $this->assertEqual($element->get_width(), px2pt(100));
     $element =& $tree->get_element_by_id('div5');
     $this->assertEqual($element->get_width(), px2pt(100));
     $element =& $tree->get_element_by_id('div6');
     $this->assertEqual($element->get_width(), px2pt(100));
     $element =& $tree->get_element_by_id('div7');
     $this->assertEqual($element->get_width(), px2pt(100));
     $element =& $tree->get_element_by_id('div8');
     $this->assertWithinMargin($element->get_width(), $pipeline->output_driver->stringwidth('Right', 'Times-Roman', 'iso-8859-1', $base), 0);
     $element =& $tree->get_element_by_id('div9');
     $this->assertEqual($element->get_width(), mm2pt($media->real_width()) - px2pt(100), 'DIV with long text and "left" property has incorrect width [%s]');
     $element =& $tree->get_element_by_id('div10');
     $this->assertEqual($element->get_width(), mm2pt($media->real_width()) - px2pt(100), 'DIV with long text and "right" property has incorrect width [%s]');
     $element =& $tree->get_element_by_id('div11');
     $this->assertEqual($element->get_width(), mm2pt($media->real_width()), 'DIV with long text and no positioning properties has incorrect width [%s]');
     $element =& $tree->get_element_by_id('div12');
     $this->assertEqual($element->get_width(), mm2pt($media->real_width()) - px2pt(200), 'DIV with long text and both "left" and "right" properties has incorrect width [%s]');
 }
开发者ID:aedvalson,项目名称:Nexus,代码行数:32,代码来源:test.width.absolute.positioned.php

示例6: parse

 function parse($value)
 {
     if ($value == '') {
         return null;
     }
     // First attempt to create media with predefined name
     if (preg_match('/^(\\w+)(?:\\s+(portrait|landscape))?$/', $value, $matches)) {
         $name = $matches[1];
         $landscape = isset($matches[2]) && $matches[2] == 'landscape';
         $media =& Media::predefined($name);
         if (is_null($media)) {
             return null;
         }
         return array('size' => array('width' => $media->get_width(), 'height' => $media->get_height()), 'landscape' => $landscape);
     }
     // Second, attempt to create media with predefined size
     $parts = preg_split('/\\s+/', $value);
     $width_str = $parts[0];
     $height_str = isset($parts[1]) ? $parts[1] : $parts[0];
     $width = units2pt($width_str);
     $height = units2pt($height_str);
     if ($width == 0 || $height == 0) {
         return null;
     }
     return array('size' => array('width' => $width / mm2pt(1) / pt2pt(1), 'height' => $height / mm2pt(1) / pt2pt(1)), 'landscape' => false);
 }
开发者ID:dadigo,项目名称:simpleinvoices,代码行数:26,代码来源:css.size.inc.php

示例7: units2pt

function units2pt($value, $font_size = null)
{
    $unit = Value::unit_from_string($value);
    switch ($unit) {
        case UNIT_PT:
            return pt2pt((double) $value);
        case UNIT_PX:
            return px2pt((double) $value);
        case UNIT_MM:
            return pt2pt(mm2pt((double) $value));
        case UNIT_CM:
            return pt2pt(mm2pt((double) $value * 10));
        case UNIT_EM:
            return em2pt((double) $value, $font_size);
        case UNIT_EX:
            return ex2pt((double) $value, $font_size);
        case UNIT_IN:
            return pt2pt((double) $value * 72);
            // points used by CSS 2.1 are equal to 1/72nd of an inch.
        // points used by CSS 2.1 are equal to 1/72nd of an inch.
        case UNIT_PC:
            return pt2pt((double) $value * 12);
            // 1 pica equals to 12 points.
        // 1 pica equals to 12 points.
        default:
            global $g_config;
            if ($g_config['mode'] === 'quirks') {
                return px2pt((double) $value);
            } else {
                return 0;
            }
    }
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:33,代码来源:utils_units.php

示例8: TestContainingBlockAbsolute1

    function TestContainingBlockAbsolute1()
    {
        $tree = $this->runPipeline('
<style type="text/css">
#container {
  padding: 10mm;
  margin: 50mm;
  position: relative;
  top: 0;
  left: 0;
}

#block {
  position: absolute;
  top: 3mm;
  left: 2mm;
  margin: 7mm;
}
</style>
<div id="container">
<div id="block">
&nbsp;
</div><!--#block-->
</div><!--#container-->
');
        $block =& $tree->get_element_by_id('block');
        $container =& $tree->get_element_by_id('container');
        $this->assertEqual($block->get_top_margin(), $container->get_top_padding() - mm2pt(3));
        $this->assertEqual($block->get_left_margin(), $container->get_left_padding() + mm2pt(2));
    }
开发者ID:sharmarakesh,项目名称:EduSec2.0.0,代码行数:30,代码来源:test.containing.block.absolute.php

示例9: TestTextareaHeight1

    function TestTextareaHeight1()
    {
        $tree = $this->runPipeline('
<textarea id="textarea" style="height: 8cm;">TEXT</textarea>
');
        $element =& $tree->get_element_by_id('textarea');
        $this->assertEqual($element->get_full_height(), mm2pt(80));
    }
开发者ID:sharmarakesh,项目名称:EduSec2.0.0,代码行数:8,代码来源:test.textarea.height.php

示例10: testCSSPageBreakAfter2

 function testCSSPageBreakAfter2()
 {
     $tree = $this->runPipeline(file_get_contents('test.css.page.break.after.2.html'), $media);
     $page_heights = PageBreakLocator::getPages($tree, mm2pt($media->real_height()), mm2pt($media->height() - $media->margins['top']));
     $this->assertEqual(count($page_heights), 2);
     $div = $tree->get_element_by_id('div');
     $h1 = $tree->get_element_by_id('h1');
     $this->assertEqual($page_heights[0], $div->get_full_height());
 }
开发者ID:aedvalson,项目名称:Nexus,代码行数:9,代码来源:test.css.page.break.after.php

示例11: run

 function run(&$pipeline, &$media, &$box)
 {
     $num_pages = ceil($box->get_height() / mm2pt($media->real_height()));
     $page_heights = array();
     for ($i = 0; $i < $num_pages; $i++) {
         $page_heights[] = mm2pt($media->real_height());
     }
     return $page_heights;
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:9,代码来源:strategy.page.break.simple.php

示例12: testPagebreakFixedHeight1

 function testPagebreakFixedHeight1()
 {
     $media = new Media(array('width' => 100, 'height' => 200 / mm2pt(1)), array('top' => 0, 'bottom' => 0, 'left' => 0, 'right' => 0));
     $tree = $this->runPipeline(file_get_contents('test.pagebreak.fixed.height.1.html'), $media);
     $page_heights = PageBreakLocator::getPages($tree, mm2pt($media->real_height()), mm2pt($media->height() - $media->margins['top']));
     $div = $tree->get_element_by_id('div');
     $this->assertEqual(count($page_heights), 2, sprintf("Two pages expected, got %s", count($page_heights)));
     $this->assertEqual($page_heights[0], 200);
 }
开发者ID:aedvalson,项目名称:Nexus,代码行数:9,代码来源:test.pagebreak.fixed.height.php

示例13: guess_page

 function guess_page(&$element, $page_heights, &$media)
 {
     $page_index = 0;
     $bottom = mm2pt($media->height() - $media->margins['top']);
     do {
         $bottom -= $page_heights[$page_index];
         $page_index++;
     } while ($element->get_top() < $bottom);
     return $page_index;
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:10,代码来源:toc.php

示例14: handle_before_page_heights

 function handle_before_page_heights($params)
 {
     $pipeline =& $params['pipeline'];
     $document =& $params['document'];
     $media =& $params['media'];
     $boxes = $pipeline->reflow_margin_boxes(0, $media);
     $this->_top_margin = 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());
     $this->_bottom_margin = 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());
     $media->margins['top'] = $this->_top_margin / mm2pt(1);
     $media->margins['bottom'] = $this->_bottom_margin / mm2pt(1);
     $pipeline->output_driver->update_media($media);
     $pipeline->_setupScales($media);
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:13,代码来源:automargins.php

示例15: testLineBoxTop1

    function testLineBoxTop1()
    {
        $media = new Media(array('width' => 100, 'height' => 200 / mm2pt(1)), array('top' => 0, 'bottom' => 0, 'left' => 0, 'right' => 0));
        $tree = $this->runPipeline('
<html>
<head>
body   { font-size: 10pt; line-height: 1; padding: 0; margin: 0; }
</style>
</head>
<body>TEXT</body>
</html>
', $media);
        $line_box = $tree->content[0]->getLineBox(0);
        $this->assertEqual($tree->content[0]->get_top(), $line_box->top, "Comparing line box top and inline box top [%s]");
    }
开发者ID:sharmarakesh,项目名称:EduSec2.0.0,代码行数:15,代码来源:test.line-box.top.php


注:本文中的mm2pt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。