note 31673 deleted from function.pdf-setcolor by john
| From: | john@php.net | Date: | Mon, 30 Jun 2003 01:12:00 +0000 |
| Subject: | note 31673 deleted from function.pdf-setcolor by john | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-51173@lists.php.net to get a copy of this message | ||
Note Submitter: php at perfectweb dotcom
----
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'); ## second parameter should be
"fill", "stroke" or "both"
-Derek