Recommend this page to a friend! |
Print Form PDF | > | All threads | > | printform-pdf.php incompatable with... | > | (Un) Subscribe thread alerts |
|
Chris Hiebert - 2013-05-22 17:58:22
printform-pdf.php references function convertHTMLColorToDec.
The current version of tcpdf has moved convertHTMLColorToDec into the static class TCPDF_COLORS. I was able to get the example functioning by changing the references of this->_pdf->convertHTMLColorToDec to TCPDF_COLORS::convertHTMLColorToDec example: $color = TCPDF_COLORS::convertHTMLColorToDec((string)$param);
Alexander Selifonov - 2013-05-22 19:04:02 - In reply to message 1 from Chris Hiebert
Hello Chris, thanks for notification.
I've fixed source code, so PrintformPDF can be used with old and latest TCPDF versions.
Chris Hiebert - 2013-06-12 21:48:56 - In reply to message 2 from Alexander Selifonov
The new function also requires a second parm for Spot Colors.
Also, they don't make the TCPDF object's spot colors public. To fix this I added another class variable. private $_spot_colors = array(); And passed it into the function: if(class_exists('TCPDF_COLORS')) return TCPDF_COLORS::convertHTMLColorToDec($clr, $this->_spot_colors ); Idealy TCPDF would make the second parm in convertHTMLColorToDec optional.
Alexander Selifonov - 2013-06-16 06:49:41 - In reply to message 3 from Chris Hiebert
Fixed. (I don't use PHP 5.3, so couldn't test pervious update with TCPDF 6.0.18)
arron wall - 2013-12-26 03:29:00 - In reply to message 1 from Chris Hiebert
I am using another PDF printing driver:
yiigo.com/guides/csharp/how-to-prin ...And I haven't met such a problem.
Ilidio - 2014-05-28 10:57:03 - In reply to message 1 from Chris Hiebert
You can add the following function to tcpdf.pdf classe and do no changes
/** * Returns an array (RGB or CMYK) from an html color name, or a six-digit (i.e. #3FE5AA), or three-digit (i.e. #7FF) hexadecimal color, or a javascript color array, or javascript color name. * @param $hcolor (string) HTML color. * @param $spotc (array) Reference to an array of spot colors. * @param $defcol (array) Color to return in case of error. * @return array RGB or CMYK color, or false in case of error. * @public static */ public static function convertHTMLColorToDec($hcolor) { $color = preg_replace('/[\s]*/', '', $hcolor); // remove extra spaces $color = strtolower($color); // check for javascript color array syntax if (strpos($color, '[') !== false) { if (preg_match('/[\[][\"\'](t|g|rgb|cmyk)[\"\'][\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\]]/', $color, $m) > 0) { $returncolor = array(); switch ($m[1]) { case 'cmyk': { // RGB $returncolor['C'] = max(0, min(100, (floatval($m[2]) * 100))); $returncolor['M'] = max(0, min(100, (floatval($m[3]) * 100))); $returncolor['Y'] = max(0, min(100, (floatval($m[4]) * 100))); $returncolor['K'] = max(0, min(100, (floatval($m[5]) * 100))); break; } case 'rgb': { // RGB $returncolor['R'] = max(0, min(255, (floatval($m[2]) * 255))); $returncolor['G'] = max(0, min(255, (floatval($m[3]) * 255))); $returncolor['B'] = max(0, min(255, (floatval($m[4]) * 255))); break; } case 'g': { // grayscale $returncolor['G'] = max(0, min(255, (floatval($m[2]) * 255))); break; } case 't': default: { // transparent (empty array) break; } } return $returncolor; } } elseif ((substr($color, 0, 4) != 'cmyk') AND (substr($color, 0, 3) != 'rgb') AND (($dotpos = strpos($color, '.')) !== false)) { // remove class parent (i.e.: color.red) $color = substr($color, ($dotpos + 1)); if ($color == 'transparent') { // transparent (empty array) return array(); } } if (strlen($color) == 0) { return $defcol; } // RGB ARRAY if (substr($color, 0, 3) == 'rgb') { $codes = substr($color, 4); $codes = str_replace(')', '', $codes); $returncolor = explode(',', $codes); foreach ($returncolor as $key => $val) { if (strpos($val, '%') > 0) { // percentage $returncolor[$key] = (255 * intval($val) / 100); } else { $returncolor[$key] = intval($val); } // normalize value $returncolor[$key] = max(0, min(255, $returncolor[$key])); } return $returncolor; } // CMYK ARRAY if (substr($color, 0, 4) == 'cmyk') { $codes = substr($color, 5); $codes = str_replace(')', '', $codes); $returncolor = explode(',', $codes); foreach ($returncolor as $key => $val) { if (strpos($val, '%') !== false) { // percentage $returncolor[$key] = (100 * intval($val) / 100); } else { $returncolor[$key] = intval($val); } // normalize value $returncolor[$key] = max(0, min(100, $returncolor[$key])); } return $returncolor; } if ($color[0] != '#') { // COLOR NAME if (isset(self::$webcolor[$color])) { // web color $color_code = self::$webcolor[$color]; } else { // spot color $returncolor = self::getSpotColor($color, $spotc); if ($returncolor === false) { $returncolor = $defcol; } return $returncolor; } } else { $color_code = substr($color, 1); } // HEXADECIMAL REPRESENTATION switch (strlen($color_code)) { case 3: { // 3-digit RGB hexadecimal representation $r = substr($color_code, 0, 1); $g = substr($color_code, 1, 1); $b = substr($color_code, 2, 1); $returncolor = array(); $returncolor['R'] = max(0, min(255, hexdec($r.$r))); $returncolor['G'] = max(0, min(255, hexdec($g.$g))); $returncolor['B'] = max(0, min(255, hexdec($b.$b))); break; } case 6: { // 6-digit RGB hexadecimal representation $returncolor = array(); $returncolor['R'] = max(0, min(255, hexdec(substr($color_code, 0, 2)))); $returncolor['G'] = max(0, min(255, hexdec(substr($color_code, 2, 2)))); $returncolor['B'] = max(0, min(255, hexdec(substr($color_code, 4, 2)))); break; } case 8: { // 8-digit CMYK hexadecimal representation $returncolor = array(); $returncolor['C'] = max(0, min(100, round(hexdec(substr($color_code, 0, 2)) / 2.55))); $returncolor['M'] = max(0, min(100, round(hexdec(substr($color_code, 2, 2)) / 2.55))); $returncolor['Y'] = max(0, min(100, round(hexdec(substr($color_code, 4, 2)) / 2.55))); $returncolor['K'] = max(0, min(100, round(hexdec(substr($color_code, 6, 2)) / 2.55))); break; } default: { $returncolor = $defcol; break; } } return $returncolor; } |
info at phpclasses dot org
.