• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mm2pt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testCSSParseMarginBoxesTopLeftSize

 function testCSSParseMarginBoxesTopLeftSize()
 {
     parse_config_file('../html2ps.config');
     $media =& Media::predefined('A4');
     $media->set_margins(array('left' => 10, 'top' => 10, 'right' => 10, 'bottom' => 10));
     $pipeline =& PipelineFactory::create_default_pipeline('utf-8', 'test.pdf');
     $pipeline->_prepare($media);
     $pipeline->_cssState = array(new CSSState(CSS::get()));
     parse_css_atpage_rules('@page { @top-left { content: "TEXT"; } }', $pipeline);
     $boxes = $pipeline->reflow_margin_boxes(1, $media);
     $box =& $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT];
     $this->assertNotEqual($box->get_width(), 0);
     $expected_width = $pipeline->output_driver->stringwidth('TEXT', 'Times-Roman', 'iso-8859-1', 12);
     $this->assertTrue($box->get_width() >= $expected_width);
     $this->assertEqual($box->get_height(), mm2pt(10));
 }
开发者ID:sharmarakesh,项目名称:EduSec2.0.0,代码行数:16,代码来源:test.css.margin.boxes.php


示例17: testTableColumnWidth4

 function testTableColumnWidth4()
 {
     $media = null;
     $tree = $this->runPipeline(file_get_contents('test.table.column.width.4.html'), $media);
     $container_table =& $tree->get_element_by_id('table');
     $cell1 =& $tree->get_element_by_id('cell1');
     $cell2 =& $tree->get_element_by_id('cell2');
     $cell =& $tree->get_element_by_id('container-cell');
     $this->assertEqual($container_table->get_width(), mm2pt($media->real_width()) * 0.9);
     $container_cell_width = $cell->get_width();
     $container_cell_min_width = $cell->content[0]->get_width();
     $this->assertTrue($container_cell_min_width <= $container_cell_width, sprintf('Container cell width (%s) is less than content minimal width (%s)', $container_cell_width, $container_cell_min_width));
     $cell_width = $cell1->get_width() + $cell2->get_width() + $cell->get_width();
     $table_width = $container_table->get_width();
     $this->assertTrue($cell_width <= $table_width, sprintf('Total cell width (%s) is greater than table width (%s)', $cell_width, $table_width));
 }
开发者ID:aedvalson,项目名称:Nexus,代码行数:16,代码来源:test.table.column.width.php


示例18: units2pt

function units2pt($value, $font_size = null)
{
    $units = substr($value, strlen($value) - 2, 2);
    switch ($units) {
        case "pt":
            return pt2pt((double) $value);
        case "px":
            return px2pt((double) $value);
        case "mm":
            return mm2pt((double) $value);
        case "cm":
            return mm2pt((double) $value * 10);
            // FIXME: check if it will work correcty in all situations (order of css rule application may vary).
        // FIXME: check if it will work correcty in all situations (order of css rule application may vary).
        case "em":
            if (is_null($font_size)) {
                $fs = get_font_size();
                //       $fs_parts = explode(" ", $fs);
                //       if (count($fs_parts) == 2) {
                //         return units2pt(((double)$value) * $fs_parts[0]*EM_KOEFF . $fs_parts[1]);
                //       } else {
                return pt2pt((double) $value * $fs * EM_KOEFF);
                //       };
            } else {
                return $font_size * (double) $value * EM_KOEFF;
            }
        case "ex":
            if (is_null($font_size)) {
                $fs = get_font_size();
                //       $fs_parts = explode(" ", $fs);
                //       if (count($fs_parts) == 2) {
                //         return units2pt(((double)$value) * $fs_parts[0]*EX_KOEFF . $fs_parts[1]);
                //       } else {
                return pt2pt((double) $value * $fs * EX_KOEFF);
                //       };
            } else {
                return $font_size * (double) $value * EX_KOEFF;
            }
        default:
            global $g_config;
            if ($g_config['mode'] === 'quirks') {
                return px2pt((double) $value);
            } else {
                return 0;
            }
    }
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:47,代码来源:utils_units.php


示例19: testPositionHorizontalbsolutePositioned1

 function testPositionHorizontalbsolutePositioned1()
 {
     $media = null;
     $pipeline = null;
     $tree = $this->runPipeline(file_get_contents('test.position.horizontal.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->assertEqual($element->get_left(), mm2pt($media->margins['left']), 'DIV with no positioning is positioned incorrectly [%s]');
     $element =& $tree->get_element_by_id('div2');
     $this->assertEqual($element->get_left(), mm2pt($media->margins['left']) + px2pt(100), 'DIV with "left" property is positioned incorrectly [%s]');
     $element =& $tree->get_element_by_id('div3');
     $this->assertEqual($element->get_right(), mm2pt($media->width() - $media->margins['right']) - px2pt(100), 'DIV with "right" property is positioned incorrectly [%s]');
     $element =& $tree->get_element_by_id('div4');
     $this->assertEqual($element->get_left(), mm2pt($media->margins['left']), 'DIV with long text and "right" property is positioned incorrectly [%s]');
     $element =& $tree->get_element_by_id('div5');
     $this->assertEqual($element->get_left(), mm2pt($media->margins['left']) + px2pt(100), 'DIV with long text and "left" property is positioned incorrectly [%s]');
 }
开发者ID:aedvalson,项目名称:Nexus,代码行数:18,代码来源:test.position.horizontal.absolute.positioned.php


示例20: TestTableAbsolute1

    function TestTableAbsolute1()
    {
        $tree = $this->runPipeline('
<style type="text/css">
body {
  margin: 0;
  padding: 0;
}
</style>
<table id="table" style="position: absolute; left: 11mm; top: 17mm;" cellpadding="0" cellspacing="0">
<tr><td>&nbsp;</td></tr>
</table>
');
        $table = $tree->get_element_by_id('table');
        $body = $tree->get_body();
        $this->assertEqual($table->get_top_margin(), $body->get_top() - mm2pt(17));
        $this->assertEqual($table->get_left_margin(), mm2pt(11));
    }
开发者ID:sharmarakesh,项目名称:EduSec2.0.0,代码行数:18,代码来源:test.table.absolute.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mm_ToolTip函数代码示例发布时间:2022-05-15
下一篇:
PHP mlm_core_get_table_prefix函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap