diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index b467894..1b5c520 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,11 @@ +6.0.037 (2013-09-30) + - Method getAllSpotColors() was added to return all spot colors. + - Method colorRegistrationBar() was extended to automatically print all spot colors and support individual spot colors. + - The method registrationMarkCMYK() was added to print a registration mark for CMYK colors. + - A bug related to page groups was fixed. + - Gradient() method now supports CMYK equivalents of spot colors. + - Example n. 56 was updated. + 6.0.036 (2013-09-29) - Methods for registration bars and crop marks were extended to support registration color (see example n. 56). - New default spot colors were added to tcpdf_colors.php, including the 'All' and 'None' special registration colors. diff --git a/README.TXT b/README.TXT index 2c79a62..18d6974 100644 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.036 -Release date: 2013-09-29 +Version: 6.0.037 +Release date: 2013-09-30 Author: Nicola Asuni Copyright (c) 2002-2013: diff --git a/composer.json b/composer.json index ace8ad9..ce1dc33 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.036", + "version": "6.0.037", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/examples/example_037.php b/examples/example_037.php index a2abf8f..deb7d92 100644 --- a/examples/example_037.php +++ b/examples/example_037.php @@ -2,7 +2,7 @@ //============================================================+ // File name : example_037.php // Begin : 2008-09-12 -// Last Update : 2013-05-14 +// Last Update : 2013-09-30 // // Description : Example 037 for TCPDF class // Spot colors @@ -86,7 +86,11 @@ $pdf->SetFont('helvetica', '', 10); $pdf->AddSpotColor('My TCPDF Dark Green', 100, 50, 80, 45); $pdf->AddSpotColor('My TCPDF Light Yellow', 0, 0, 55, 0); - +$pdf->AddSpotColor('My TCPDF Black', 0, 0, 0, 100); +$pdf->AddSpotColor('My TCPDF Red', 30, 100, 90, 10); +$pdf->AddSpotColor('My TCPDF Green', 100, 30, 100, 0); +$pdf->AddSpotColor('My TCPDF Blue', 100, 60, 10, 5); +$pdf->AddSpotColor('My TCPDF Yellow', 0, 20, 100, 0); // Select the spot color // $tint (the second parameter) is the intensity of the color (0-100). diff --git a/examples/example_056.php b/examples/example_056.php index 6c30656..c3dfe25 100644 --- a/examples/example_056.php +++ b/examples/example_056.php @@ -2,7 +2,7 @@ //============================================================+ // File name : example_056.php // Begin : 2010-03-26 -// Last Update : 2013-09-29 +// Last Update : 2013-09-30 // // Description : Example 056 for TCPDF class // Crop marks and color registration bars @@ -67,21 +67,22 @@ if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { // --------------------------------------------------------- // set font -$pdf->SetFont('helvetica', '', 20); +$pdf->SetFont('helvetica', '', 18); // add a page $pdf->AddPage(); -$pdf->Write(0, 'Example of Crop Marks and Color Registration Bars', '', 0, 'L', true, 0, false, false, 0); +$pdf->Write(0, 'Example of Registration Marks, Crop Marks and Color Bars', '', 0, 'L', true, 0, false, false, 0); $pdf->Ln(5); // color registration bars +// A,W,R,G,B,C,M,Y,K,RGB,CMYK,ALL,ALLSPOT, $pdf->colorRegistrationBar(50, 70, 40, 40, true, false, 'A,R,G,B,C,M,Y,K'); $pdf->colorRegistrationBar(90, 70, 40, 40, true, true, 'A,R,G,B,C,M,Y,K'); -$pdf->colorRegistrationBar(50, 115, 80, 5, false, true, 'A,W,R,G,B,C,M,Y,K'); -$pdf->colorRegistrationBar(135, 70, 5, 50, false, false, 'A,W,R,G,B,C,M,Y,K'); +$pdf->colorRegistrationBar(50, 115, 80, 5, false, true, 'A,W,R,G,B,C,M,Y,K,ALL'); +$pdf->colorRegistrationBar(135, 70, 5, 50, false, false, 'A,W,R,G,B,C,M,Y,K,ALL'); // corner crop marks @@ -105,7 +106,22 @@ $pdf->cropMark(95, 140, 5, 5, 'A,D', array(0,0,255)); $pdf->registrationMark(40, 60, 5, false); $pdf->registrationMark(150, 60, 5, true, array(0,0,0), array(255,255,0)); $pdf->registrationMark(40, 130, 5, true, array(0,0,0), array(255,255,0)); -$pdf->registrationMark(150, 130, 5, false, array(0,0,0,0,'None'), array(100,100,100,100,'All')); +$pdf->registrationMark(150, 130, 5, false, array(100,100,100,100,'All'), array(0,0,0,0,'None')); + +// test registration bar with spot colors + +$pdf->AddSpotColor('My TCPDF Dark Green', 100, 50, 80, 45); +$pdf->AddSpotColor('My TCPDF Light Yellow', 0, 0, 55, 0); +$pdf->AddSpotColor('My TCPDF Black', 0, 0, 0, 100); +$pdf->AddSpotColor('My TCPDF Red', 30, 100, 90, 10); +$pdf->AddSpotColor('My TCPDF Green', 100, 30, 100, 0); +$pdf->AddSpotColor('My TCPDF Blue', 100, 60, 10, 5); +$pdf->AddSpotColor('My TCPDF Yellow', 0, 20, 100, 0); + +$pdf->colorRegistrationBar(50, 150, 80, 10, false, true, 'ALLSPOT'); + +// CMYK registration mark +$pdf->registrationMarkCMYK(150, 155, 8); // --------------------------------------------------------- diff --git a/include/tcpdf_colors.php b/include/tcpdf_colors.php index 2369be6..6475285 100644 --- a/include/tcpdf_colors.php +++ b/include/tcpdf_colors.php @@ -1,9 +1,9 @@ array( 0, 100, 100, 0, 'Red'), 'green' => array(100, 0, 100, 0, 'Green'), 'blue' => array(100, 100, 0, 0, 'Blue'), - // the following are just examples, fill the array with your own values - 'mytcpdfblack' => array(0, 0, 0, 100, 'My TCPDF Black'), - 'mytcpdfred' => array(30, 100, 90, 10, 'My TCPDF Red'), - 'mytcpdfgreen' => array(100, 30, 100, 0, 'My TCPDF Green'), - 'mytcpdfblue' => array(100, 60, 10, 5, 'My TCPDF Blue'), - 'mytcpdfyellow' => array(0, 20, 100, 0, 'My TCPDF Yellow'), + // Add here standard spot colors or dynamically define them with AddSpotColor() // ... ); // end of spot colors diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index 937deb0..ee4bcb7 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.036'; + private static $tcpdf_version = '6.0.037'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index 4d2e712..aefdd55 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.036 + * @version 6.0.037 */ // TCPDF configuration @@ -128,7 +128,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php'); * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.0.036 + * @version 6.0.037 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -3652,6 +3652,16 @@ class TCPDF { return $this->page; } + /** + * Returns the array of spot colors. + * @return (array) Spot colors array. + * @public + * @since 6.0.037 (2013-09-30) + */ + public function getAllSpotColors() { + return $this->spot_colors; + } + /** * Defines a new spot color. * It can be expressed in RGB components or gray scale. @@ -7838,6 +7848,7 @@ class TCPDF { $groupnum = 0; $ptgu = 1; $ptga = 1; + $ptg_num_chars = 1; for ($n = 1; $n <= $num_pages; ++$n) { // get current page $temppage = $this->getPageBuffer($n); @@ -13919,12 +13930,25 @@ class TCPDF { * @param $h (float) height of the rectangle. * @param $transition (boolean) if true prints tcolor transitions to white. * @param $vertical (boolean) if true prints bar vertically. - * @param $colors (string) colors to print, one letter per color separated by comma (for example 'A,W,R,G,B,C,M,Y,K,RGB,CMYK,ALL'): A = grayscale black, W = grayscale white, R = RGB red, G RGB green, B RGB blue, C = CMYK cyan, M = CMYK magenta, Y = CMYK yellow, K = CMYK key/black, RGB = RGB registration color, CMYK = CMYK registration color, ALL = Spot registration color. + * @param $colors (string) colors to print separated by comma. Valid values are: A,W,R,G,B,C,M,Y,K,RGB,CMYK,ALL,ALLSPOT,. Where: A = grayscale black, W = grayscale white, R = RGB red, G RGB green, B RGB blue, C = CMYK cyan, M = CMYK magenta, Y = CMYK yellow, K = CMYK key/black, RGB = RGB registration color, CMYK = CMYK registration color, ALL = Spot registration color, ALLSPOT = print all defined spot colors, = name of the spot color to print. * @author Nicola Asuni * @since 4.9.000 (2010-03-26) * @public */ public function colorRegistrationBar($x, $y, $w, $h, $transition=true, $vertical=false, $colors='A,R,G,B,C,M,Y,K') { + if (strpos($colors, 'ALLSPOT') !== false) { + // expand spot colors + $spot_colors = ''; + foreach ($this->spot_colors as $spot_color_name => $v) { + $spot_colors .= ','.$spot_color_name; + } + if (!empty($spot_colors)) { + $spot_colors = substr($spot_colors, 1); + $colors = str_replace('ALLSPOT', $spot_colors, $colors); + } else { + $colors = str_replace('ALLSPOT', 'NONE', $colors); + } + } $bars = explode(',', $colors); $numbars = count($bars); // number of bars to print if ($numbars <= 0) { @@ -14004,23 +14028,38 @@ class TCPDF { $col_b = array(100,100,100,100); break; } - case 'ALL': - default: { // SPOT COLOR REGISTRATION + case 'ALL': { // SPOT COLOR REGISTRATION $col_a = array(0,0,0,0,'None'); $col_b = array(100,100,100,100,'All'); break; } + case 'NONE': { // SKIP THIS COLOR + $col_a = array(0,0,0,0,'None'); + $col_b = array(0,0,0,0,'None'); + break; + } + default: { // SPECIFIC SPOT COLOR NAME + $col_a = array(0,0,0,0,'None'); + $col_b = TCPDF_COLORS::getSpotColor($col, $this->spot_colors); + if ($col_b === false) { + // in case of error defaults to the registration color + $col_b = array(100,100,100,100,'All'); + } + break; + } } - if ($transition) { - // color gradient - $this->LinearGradient($xb, $yb, $wb, $hb, $col_a, $col_b, $coords); - } else { - $this->SetFillColorArray($col_b); - // colored rectangle - $this->Rect($xb, $yb, $wb, $hb, 'F', array()); + if ($col != 'NONE') { + if ($transition) { + // color gradient + $this->LinearGradient($xb, $yb, $wb, $hb, $col_a, $col_b, $coords); + } else { + $this->SetFillColorArray($col_b); + // colored rectangle + $this->Rect($xb, $yb, $wb, $hb, 'F', array()); + } + $xb += $xd; + $yb += $yd; } - $xb += $xd; - $yb += $yd; } } @@ -14108,23 +14147,63 @@ class TCPDF { * @public */ public function registrationMark($x, $y, $r, $double=false, $cola=array(100,100,100,100,'All'), $colb=array(0,0,0,0,'None')) { - $line_style = array('width' => (0.5 / $this->k), 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => $cola); + $line_style = array('width' => max((0.5 / $this->k),($r / 30)), 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => $cola); $this->SetFillColorArray($cola); $this->PieSector($x, $y, $r, 90, 180, 'F'); $this->PieSector($x, $y, $r, 270, 360, 'F'); $this->Circle($x, $y, $r, 0, 360, 'C', $line_style, array(), 8); if ($double) { - $r2 = $r * 0.5; + $ri = $r * 0.5; $this->SetFillColorArray($colb); - $this->PieSector($x, $y, $r2, 90, 180, 'F'); - $this->PieSector($x, $y, $r2, 270, 360, 'F'); + $this->PieSector($x, $y, $ri, 90, 180, 'F'); + $this->PieSector($x, $y, $ri, 270, 360, 'F'); $this->SetFillColorArray($cola); - $this->PieSector($x, $y, $r2, 0, 90, 'F'); - $this->PieSector($x, $y, $r2, 180, 270, 'F'); - $this->Circle($x, $y, $r2, 0, 360, 'C', $line_style, array(), 8); + $this->PieSector($x, $y, $ri, 0, 90, 'F'); + $this->PieSector($x, $y, $ri, 180, 270, 'F'); + $this->Circle($x, $y, $ri, 0, 360, 'C', $line_style, array(), 8); } } + /** + * Paints a CMYK registration mark + * @param $x (float) abscissa of the registration mark center. + * @param $y (float) ordinate of the registration mark center. + * @param $r (float) radius of the crop mark. + * @author Nicola Asuni + * @since 6.0.037 (2013-09-30) + * @public + */ + public function registrationMarkCMYK($x, $y, $r) { + // line width + $lw = max((0.5 / $this->k),($r / 8)); + // internal radius + $ri = ($r * 0.6); + // external radius + $re = ($r * 1.3); + // Cyan + $this->SetFillColorArray(array(100,0,0,0)); + $this->PieSector($x, $y, $ri, 270, 360, 'F'); + // Magenta + $this->SetFillColorArray(array(0,100,0,0)); + $this->PieSector($x, $y, $ri, 0, 90, 'F'); + // Yellow + $this->SetFillColorArray(array(0,0,100,0)); + $this->PieSector($x, $y, $ri, 90, 180, 'F'); + // Key - black + $this->SetFillColorArray(array(0,0,0,100)); + $this->PieSector($x, $y, $ri, 180, 270, 'F'); + // registration color + $line_style = array('width' => $lw, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(100,100,100,100,'All')); + $this->SetFillColorArray(array(100,100,100,100,'All')); + // external circle + $this->Circle($x, $y, $r, 0, 360, 'C', $line_style, array(), 8); + // cross lines + $this->Line($x, ($y - $re), $x, ($y - $ri)); + $this->Line($x, ($y + $ri), $x, ($y + $re)); + $this->Line(($x - $re), $y, ($x - $ri), $y); + $this->Line(($x + $ri), $y, ($x + $re), $y); + } + /** * Paints a linear colour gradient. * @param $x (float) abscissa of the top left corner of the rectangle. @@ -14328,7 +14407,7 @@ class TCPDF { } break; } - case 1: { // Gray scale + case 1: { // GRAY SCALE $this->gradients[$n]['colspace'] = 'DeviceGray'; if (!empty($background)) { $this->gradients[$n]['background'] = sprintf('%F', $bcolor[0]/255); @@ -14370,6 +14449,7 @@ class TCPDF { // set colors $color = array_values($stop['color']); switch($numcolspace) { + case 5: // SPOT case 4: { // CMYK $this->gradients[$n]['colors'][$key]['color'] = sprintf('%F %F %F %F', $color[0]/100, $color[1]/100, $color[2]/100, $color[3]/100); break; @@ -14378,7 +14458,7 @@ class TCPDF { $this->gradients[$n]['colors'][$key]['color'] = sprintf('%F %F %F', $color[0]/255, $color[1]/255, $color[2]/255); break; } - case 1: { // Gray scale + case 1: { // GRAY SCALE $this->gradients[$n]['colors'][$key]['color'] = sprintf('%F', $color[0]/255); break; }