本文整理汇总了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);
示例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.