example_037.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. //============================================================+
  3. // File name : example_037.php
  4. // Begin : 2008-09-12
  5. // Last Update : 2010-08-08
  6. //
  7. // Description : Example 037 for TCPDF class
  8. // Spot colors
  9. //
  10. // Author: Nicola Asuni
  11. //
  12. // (c) Copyright:
  13. // Nicola Asuni
  14. // Tecnick.com s.r.l.
  15. // Via Della Pace, 11
  16. // 09044 Quartucciu (CA)
  17. // ITALY
  18. // www.tecnick.com
  19. // info@tecnick.com
  20. //============================================================+
  21. /**
  22. * Creates an example PDF TEST document using TCPDF
  23. * @package com.tecnick.tcpdf
  24. * @abstract TCPDF - Example: Spot colors.
  25. * @author Nicola Asuni
  26. * @since 2008-09-12
  27. */
  28. require_once('../config/lang/eng.php');
  29. require_once('../tcpdf.php');
  30. // create new PDF document
  31. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  32. // set document information
  33. $pdf->SetCreator(PDF_CREATOR);
  34. $pdf->SetAuthor('Nicola Asuni');
  35. $pdf->SetTitle('TCPDF Example 037');
  36. $pdf->SetSubject('TCPDF Tutorial');
  37. $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  38. // set default header data
  39. $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 037', PDF_HEADER_STRING);
  40. // set header and footer fonts
  41. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  42. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  43. // set default monospaced font
  44. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  45. //set margins
  46. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  47. $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  48. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  49. //set auto page breaks
  50. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  51. //set image scale factor
  52. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  53. //set some language-dependent strings
  54. $pdf->setLanguageArray($l);
  55. // ---------------------------------------------------------
  56. // set font
  57. $pdf->SetFont('helvetica', '', 20);
  58. // add a page
  59. $pdf->AddPage();
  60. $pdf->Write(0, 'Example of Spot Colors', '', 0, 'L', true, 0, false, false, 0);
  61. $pdf->Ln(5);
  62. $pdf->SetFont('helvetica', '', 8);
  63. // Define some new spot colors
  64. // $c, $m, $y and $k (2nd, 3rd, 4th and 5th parameter) are the CMYK color components.
  65. // AddSpotColor($name, $c, $m, $y, $k)
  66. $pdf->AddSpotColor('Pantone 116 C', 0, 20, 100, 0);
  67. $pdf->AddSpotColor('HKS 16 K', 30, 100, 90, 10);
  68. $pdf->AddSpotColor('Pantone 505 C', 57, 100, 85, 55);
  69. $pdf->AddSpotColor('Pantone 440 C', 50, 60, 80, 70);
  70. $pdf->AddSpotColor('Pantone 288 C', 100, 60, 10, 5);
  71. $pdf->AddSpotColor('Pantone 289 C', 100, 78, 50, 0);
  72. $pdf->AddSpotColor('Pantone 356 C', 100, 30, 100, 0);
  73. $pdf->AddSpotColor('Pantone 567 C', 100, 50, 80, 45);
  74. $pdf->AddSpotColor('Pantone 9060 C', 0, 0, 7, 0);
  75. $pdf->AddSpotColor('Pantone 420 C', 22, 14, 22, 0);
  76. $pdf->AddSpotColor('Pantone 422 C', 39, 24, 34, 0);
  77. $pdf->AddSpotColor('Pantone 433 C', 34, 0, 0, 94);
  78. $pdf->AddSpotColor('NovaSpace-Black', 50, 0, 0, 100);
  79. $pdf->AddSpotColor('Pantone 601 C', 0, 0, 55, 0);
  80. $pdf->AddSpotColor('Pantone 659 C', 50, 20, 0, 10);
  81. // Select the spot color
  82. // $tint (the second parameter) is the intensity of the color (0-100).
  83. // SetTextSpotColor($name, $tint=100)
  84. // SetDrawSpotColor($name, $tint=100)
  85. // SetFillSpotColor($name, $tint=100)
  86. $pdf->SetTextSpotColor('NovaSpace-Black', 100);
  87. $pdf->SetDrawSpotColor('NovaSpace-Black', 100);
  88. $starty = 50;
  89. // print some spot colors
  90. $pdf->SetFillSpotColor('Pantone 116 C', 100);
  91. $pdf->Rect(30, $starty, 20, 6, 'DF');
  92. $pdf->Text(53, $starty + 1, 'Pantone 116 C');
  93. $starty += 8;
  94. $pdf->SetFillSpotColor('HKS 16 K', 100);
  95. $pdf->Rect(30, $starty, 20, 6, 'DF');
  96. $pdf->Text(53, $starty + 1, 'HKS 16 K');
  97. $starty += 8;
  98. $pdf->SetFillSpotColor('Pantone 505 C', 100);
  99. $pdf->Rect(30, $starty, 20, 6, 'DF');
  100. $pdf->Text(53, $starty + 1, 'Pantone 505 C');
  101. $starty += 8;
  102. $pdf->SetFillSpotColor('Pantone 440 C', 100);
  103. $pdf->Rect(30, $starty, 20, 6, 'DF');
  104. $pdf->Text(53, $starty + 1, 'Pantone 440 C');
  105. $starty += 8;
  106. $pdf->SetFillSpotColor('Pantone 288 C', 100);
  107. $pdf->Rect(30, $starty, 20, 6, 'DF');
  108. $pdf->Text(53, $starty + 1, 'Pantone 288 C');
  109. $starty += 8;
  110. $pdf->SetFillSpotColor('Pantone 289 C', 100);
  111. $pdf->Rect(30, $starty, 20, 6, 'DF');
  112. $pdf->Text(53, $starty + 1, 'Pantone 289 C');
  113. $starty += 8;
  114. $pdf->SetFillSpotColor('Pantone 356 C', 100);
  115. $pdf->Rect(30, $starty, 20, 6, 'DF');
  116. $pdf->Text(53, $starty + 1, 'Pantone 356 C');
  117. $starty += 8;
  118. $pdf->SetFillSpotColor('Pantone 567 C', 100);
  119. $pdf->Rect(30, $starty, 20, 6, 'DF');
  120. $pdf->Text(53, $starty + 1, 'Pantone 567 C');
  121. $starty += 8;
  122. $pdf->SetFillSpotColor('Pantone 9060 C', 100);
  123. $pdf->Rect(30, $starty, 20, 6, 'DF');
  124. $pdf->Text(53, $starty + 1, 'Pantone 9060 C');
  125. $starty += 8;
  126. $pdf->SetFillSpotColor('Pantone 420 C', 100);
  127. $pdf->Rect(30, $starty, 20, 6, 'DF');
  128. $pdf->Text(53, $starty + 1, 'Pantone 420 C');
  129. $starty += 8;
  130. $pdf->SetFillSpotColor('Pantone 422 C', 100);
  131. $pdf->Rect(30, $starty, 20, 6, 'DF');
  132. $pdf->Text(53, $starty + 1, 'Pantone 422 C');
  133. $starty += 8;
  134. $pdf->SetFillSpotColor('Pantone 433 C', 100);
  135. $pdf->Rect(30, $starty, 20, 6, 'DF');
  136. $pdf->Text(53, $starty + 1, 'Pantone 433 C');
  137. $starty += 8;
  138. $pdf->SetFillSpotColor('Pantone 601 C', 100);
  139. $pdf->Rect(30, $starty, 20, 6, 'DF');
  140. $pdf->Text(53, $starty + 1, 'Pantone 601 C');
  141. $starty += 8;
  142. $pdf->SetFillSpotColor('Pantone 659 C', 100);
  143. $pdf->Rect(30, $starty, 20, 6, 'DF');
  144. $pdf->Text(53, $starty + 1, 'Pantone 659 C');
  145. // ---------------------------------------------------------
  146. //Close and output PDF document
  147. $pdf->Output('example_037.pdf', 'I');
  148. //============================================================+
  149. // END OF FILE
  150. //============================================================+