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


PHP Canvas::get_cpdf方法代码示例

本文整理汇总了PHP中Canvas::get_cpdf方法的典型用法代码示例。如果您正苦于以下问题:PHP Canvas::get_cpdf方法的具体用法?PHP Canvas::get_cpdf怎么用?PHP Canvas::get_cpdf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Canvas的用法示例。


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

示例1: _background_image


//.........这里部分代码省略.........
     //Use filename as indicator only
     //different names for different variants to have different copies in the pdf
     //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color)
     //Note: Here, bg_* are the start values, not end values after going through the tile loops!
     $filedummy = $img;
     /* 
         //Make shorter strings with limited characters for cache associative array index - needed?	
     //Strip common base path - server root, explicite temp, default temp; remove unwanted characters;
     $filedummy = strtr($filedummy,"\\:","//");
     $p = strtr($_SERVER["DOCUMENT_ROOT"],"\\:","//");
     $l = strlen($p);
     if ( substr($filedummy,0,$l) == $p) {
       $filedummy = substr($filedummy,$l);
     } else {
           $p = strtr(DOMPDF_TEMP_DIR,"\\:","//");
       $l = strlen($p);
       if ( substr($filedummy,0,$l) == $p) {
         $filedummy = substr($filedummy,$l);
       } else {
             $p = strtr(sys_get_temp_dir(),"\\:","//");
         $l = strlen($p);
         if ( substr($filedummy,0,$l) == $p) {
           $filedummy = substr($filedummy,$l);
         }
       }
     }
     */
     $filedummy .= '_' . $bg_width . '_' . $bg_height . '_' . $bg_x . '_' . $bg_y . '_' . $repeat;
     //debugpng
     //if (DEBUGPNG) print '<pre>[_background_image name '.$filedummy.']</pre>';
     //Optimization to avoid multiple times rendering the same image.
     //If check functions are existing and identical image already cached,
     //then skip creation of duplicate, because it is not needed by addImagePng
     if (method_exists($this->_canvas, "get_cpdf") && method_exists($this->_canvas->get_cpdf(), "addImagePng") && method_exists($this->_canvas->get_cpdf(), "image_iscached") && $this->_canvas->get_cpdf()->image_iscached($filedummy)) {
         $bg = null;
         //debugpng
         //if (DEBUGPNG) print '[_background_image skip]';
     } else {
         // Create a new image to fit over the background rectangle
         $bg = imagecreatetruecolor($bg_width, $bg_height);
         //anyway default
         //imagealphablending($img, true);
         switch (strtolower($ext)) {
             case "png":
                 $src = imagecreatefrompng($img);
                 break;
             case "jpg":
             case "jpeg":
                 $src = imagecreatefromjpeg($img);
                 break;
             case "gif":
                 $src = imagecreatefromgif($img);
                 break;
             default:
                 return;
                 // Unsupported image type
         }
         if ($src == null) {
             return;
         }
         //Background color if box is not relevant here
         //Non transparent image: box clipped to real size. Background non relevant.
         //Transparent image: The image controls the transparency and lets shine through whatever background.
         //However on transparent imaage preset the composed image with the transparency color,
         //to keep the transparency when copying over the non transparent parts of the tiles.
         $ti = imagecolortransparent($src);
开发者ID:kuwox,项目名称:buenavista,代码行数:67,代码来源:abstract_renderer.cls.php

示例2: _background_image


//.........这里部分代码省略.........
         }
         $height = (double) ($bg_height * 72) / $dpi;
     } else {
         //repeat y
         if ($bg_y < 0) {
             $bg_y = -(-$bg_y % $img_h);
         } else {
             $bg_y = $bg_y % $img_h;
             if ($bg_y > 0) {
                 $bg_y -= $img_h;
             }
         }
     }
     //Optimization, if repeat has no effect
     if ($repeat === "repeat" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) {
         $repeat = "repeat-x";
     }
     if ($repeat === "repeat" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) {
         $repeat = "repeat-y";
     }
     if ($repeat === "repeat-x" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width || $repeat === "repeat-y" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) {
         $repeat = "no-repeat";
     }
     //Use filename as indicator only
     //different names for different variants to have different copies in the pdf
     //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color)
     //Note: Here, bg_* are the start values, not end values after going through the tile loops!
     $filedummy = $img;
     $is_png = false;
     $filedummy .= '_' . $bg_width . '_' . $bg_height . '_' . $bg_x . '_' . $bg_y . '_' . $repeat;
     //Optimization to avoid multiple times rendering the same image.
     //If check functions are existing and identical image already cached,
     //then skip creation of duplicate, because it is not needed by addImagePng
     if ($this->_canvas instanceof CPDF_Adapter && $this->_canvas->get_cpdf()->image_iscached($filedummy)) {
         $bg = null;
     } else {
         // Create a new image to fit over the background rectangle
         $bg = imagecreatetruecolor($bg_width, $bg_height);
         switch (strtolower($type)) {
             case IMAGETYPE_PNG:
                 $is_png = true;
                 imagesavealpha($bg, true);
                 imagealphablending($bg, false);
                 $src = imagecreatefrompng($img);
                 break;
             case IMAGETYPE_JPEG:
                 $src = imagecreatefromjpeg($img);
                 break;
             case IMAGETYPE_GIF:
                 $src = imagecreatefromgif($img);
                 break;
             case IMAGETYPE_BMP:
                 $src = imagecreatefrombmp($img);
                 break;
             default:
                 return;
                 // Unsupported image type
         }
         if ($src == null) {
             return;
         }
         //Background color if box is not relevant here
         //Non transparent image: box clipped to real size. Background non relevant.
         //Transparent image: The image controls the transparency and lets shine through whatever background.
         //However on transparent image preset the composed image with the transparency color,
         //to keep the transparency when copying over the non transparent parts of the tiles.
开发者ID:uab-balticode,项目名称:dpd-shipping-module-magento-2,代码行数:67,代码来源:abstract_renderer.cls.php


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