Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

PDF_setcolor

(PHP 4 >= 4.0.5, PECL)

PDF_setcolor -- Set fill and stroke color

Описание

bool PDF_setcolor ( resource p, string fstype, string colorspace, float c1, float c2, float c3, float c4 )

Sets the current color space and color. Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.



PDF_setdash> <PDF_set_word_spacing
Last updated: Fri, 26 Jan 2007
 
add a note add a note User Contributed Notes
PDF_setcolor
_meto ALT+q web.de
08-May-2004 09:03
Damn, this took me some real long time! Maybe it's helpfull for those who even have no idea of color-Schemes like me ;)

If u want to generate PDF's for Print Offices u need to set all the colors in CMYK.

Here is a Function that will convert RGB to CMYK

<?
function hex2rgb($hex) {
  $color = str_replace('#','',$hex);
  $rgb = array('r' => hexdec(substr($color,0,2)),
               'g' => hexdec(substr($color,2,2)),
               'b' => hexdec(substr($color,4,2)));
  return $rgb;
}

function rgb2cmyk($var1,$g=0,$b=0) {
   if(is_array($var1)) {
      $r = $var1['r'];
      $g = $var1['g'];
      $b = $var1['b'];
   }
   else $r=$var1;
   $cyan    = 255 - $r;
   $magenta = 255 - $g;
   $yellow  = 255 - $b;
   $black   = min($cyan, $magenta, $yellow);
   $cyan    = @(($cyan    - $black) / (255 - $black)) * 255;
   $magenta = @(($magenta - $black) / (255 - $black)) * 255;
   $yellow  = @(($yellow  - $black) / (255 - $black)) * 255;
   return array('c' => $cyan / 255,
                'm' => $magenta / 255,
                'y' => $yellow / 255,
                'k' => $black / 255);
}

$color=rgb2cmyk(hex2rgb('#FF0000'));
pdf_setcolor($pdf, "both", "cmyk", $color['c'], $color['m'], $color['y'], $color['k']);
?>

U can call it with parameters (r,g,b) or just an array(r,g,b) that contains these values.

Hope it works correct. All testing was fine.
enyo vel cora
13-Jan-2004 04:32
This seems a little less complicated:

this is the color you want to use : 'FF11AA'

<?php
pdf_setcolor
($pdf, 'both', 0xFF / 255, 0x11 / 255, 0xAA / 255);
?>
php at perfectweb dotcom
29-Apr-2003 04:22
Here's a better implementation for setting HTML hexadecimal colors:

function pdf_setcolor_hex($hexcolor, $type = '')
{
    global $pdf;     ## match this to your pdf resource handle
       $color['r'] = hexdec(substr($hexcolor, 0, 2))/255;
       $color['g'] = hexdec(substr($hexcolor, 2, 2))/255;
       $color['b'] = hexdec(substr($hexcolor, 4, 2))/255;
       if ($type != 'fill' && $type != 'stroke')  $type = 'both';
       pdf_setcolor($pdf, $type, 'rgb', $color['r'], $color['g'], $color['b']);
}

Sample usage:
pdf_setcolor_hex('FFFFFF', 'fill');

-Derek
php at perfectweb dotcom
29-Apr-2003 12:59
Here's a function for converting HTML hexadecimal colors to RGB decimals suitable for this function:

$color_hex = "FF0000";       ## whatever hex color you want
$color = convert_hexcolor_rgbdec($color_hex);
pdf_setcolor($pdf, 'fill', 'rgb', $color['r'], $color['g'], $color['b']);

function convert_hexcolor_rgbdec($color_hex)
{
   $color['r'] = hexdec(substr($color_hex, 0, 2))/255;
   $color['g'] = hexdec(substr($color_hex, 2, 2))/255;
   $color['b'] = hexdec(substr($color_hex, 4, 2))/255;
   return $color;
}

-Derek
maurice dot anglebert at free dot fr
28-Apr-2003 08:25
Bonjour,

Cette fonction est utilisable pour d
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571