You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
5.1 KiB

4 years ago
  1. <?php
  2. //============================================================+
  3. // File name : example_037.php
  4. // Begin : 2008-09-12
  5. // Last Update : 2013-09-30
  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 LTD
  15. // www.tecnick.com
  16. // info@tecnick.com
  17. //============================================================+
  18. /**
  19. * Creates an example PDF TEST document using TCPDF
  20. * @package com.tecnick.tcpdf
  21. * @abstract TCPDF - Example: Spot colors.
  22. * @author Nicola Asuni
  23. * @since 2008-09-12
  24. */
  25. // Include the main TCPDF library (search for installation path).
  26. require_once('tcpdf_include.php');
  27. // create new PDF document
  28. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  29. // set document information
  30. $pdf->SetCreator(PDF_CREATOR);
  31. $pdf->SetAuthor('Nicola Asuni');
  32. $pdf->SetTitle('TCPDF Example 037');
  33. $pdf->SetSubject('TCPDF Tutorial');
  34. $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  35. // set default header data
  36. $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 037', PDF_HEADER_STRING);
  37. // set header and footer fonts
  38. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  39. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  40. // set default monospaced font
  41. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  42. // set margins
  43. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  44. $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  45. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  46. // set auto page breaks
  47. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  48. // set image scale factor
  49. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  50. // set some language-dependent strings (optional)
  51. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  52. require_once(dirname(__FILE__).'/lang/eng.php');
  53. $pdf->setLanguageArray($l);
  54. }
  55. // ---------------------------------------------------------
  56. // set font
  57. $pdf->SetFont('helvetica', '', 11);
  58. // add a page
  59. $pdf->AddPage();
  60. $html = '<h1>Example of Spot Colors</h1>Spot colors are single ink colors, rather than colors produced by four (CMYK), six (CMYKOG) or more inks in the printing process (process colors). They can be obtained by special vendors, but often the printers have found their own way of mixing inks to match defined colors.<br /><br />As long as no open standard for spot colours exists, TCPDF users will have to buy a colour book by one of the colour manufacturers and insert the values and names of spot colours directly into the $spotcolor array in <b><em>include/tcpdf_colors.php</em></b> file, or define them using the <b><em>AddSpotColor()</em></b> method.<br /><br />Common industry standard spot colors are:<br /><span color="#008800">ANPA-COLOR, DIC, FOCOLTONE, GCMI, HKS, PANTONE, TOYO, TRUMATCH</span>.';
  61. // Print text using writeHTMLCell()
  62. $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, 'J', true);
  63. $pdf->SetFont('helvetica', '', 10);
  64. // Define some new spot colors
  65. // $c, $m, $y and $k (2nd, 3rd, 4th and 5th parameter) are the CMYK color components.
  66. // AddSpotColor($name, $c, $m, $y, $k)
  67. $pdf->AddSpotColor('My TCPDF Dark Green', 100, 50, 80, 45);
  68. $pdf->AddSpotColor('My TCPDF Light Yellow', 0, 0, 55, 0);
  69. $pdf->AddSpotColor('My TCPDF Black', 0, 0, 0, 100);
  70. $pdf->AddSpotColor('My TCPDF Red', 30, 100, 90, 10);
  71. $pdf->AddSpotColor('My TCPDF Green', 100, 30, 100, 0);
  72. $pdf->AddSpotColor('My TCPDF Blue', 100, 60, 10, 5);
  73. $pdf->AddSpotColor('My TCPDF Yellow', 0, 20, 100, 0);
  74. // Select the spot color
  75. // $tint (the second parameter) is the intensity of the color (0-100).
  76. // SetTextSpotColor($name, $tint=100)
  77. // SetDrawSpotColor($name, $tint=100)
  78. // SetFillSpotColor($name, $tint=100)
  79. $pdf->SetTextSpotColor('My TCPDF Black', 100);
  80. $pdf->SetDrawSpotColor('My TCPDF Black', 100);
  81. $starty = 100;
  82. // print some spot colors
  83. $pdf->SetFillSpotColor('My TCPDF Dark Green', 100);
  84. $pdf->Rect(30, $starty, 40, 20, 'DF');
  85. $pdf->Text(73, $starty + 8, 'My TCPDF Dark Green');
  86. $starty += 24;
  87. $pdf->SetFillSpotColor('My TCPDF Light Yellow', 100);
  88. $pdf->Rect(30, $starty, 40, 20, 'DF');
  89. $pdf->Text(73, $starty + 8, 'My TCPDF Light Yellow');
  90. // --- default values defined on spotcolors.php ---
  91. $starty += 24;
  92. $pdf->SetFillSpotColor('My TCPDF Red', 100);
  93. $pdf->Rect(30, $starty, 40, 20, 'DF');
  94. $pdf->Text(73, $starty + 8, 'My TCPDF Red');
  95. $starty += 24;
  96. $pdf->SetFillSpotColor('My TCPDF Green', 100);
  97. $pdf->Rect(30, $starty, 40, 20, 'DF');
  98. $pdf->Text(73, $starty + 8, 'My TCPDF Green');
  99. $starty += 24;
  100. $pdf->SetFillSpotColor('My TCPDF Blue', 100);
  101. $pdf->Rect(30, $starty, 40, 20, 'DF');
  102. $pdf->Text(73, $starty + 8, 'My TCPDF Blue');
  103. $starty += 24;
  104. $pdf->SetFillSpotColor('My TCPDF Yellow', 100);
  105. $pdf->Rect(30, $starty, 40, 20, 'DF');
  106. $pdf->Text(73, $starty + 8, 'My TCPDF Yellow');
  107. // ---------------------------------------------------------
  108. //Close and output PDF document
  109. $pdf->Output('example_037.pdf', 'I');
  110. //============================================================+
  111. // END OF FILE
  112. //============================================================+