example_037.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. //============================================================+
  3. // File name : example_037.php
  4. // Begin : 2008-09-12
  5. // Last Update : 2011-10-03
  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', '', 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 <b><em>spotcolors.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. // Select the spot color
  70. // $tint (the second parameter) is the intensity of the color (0-100).
  71. // SetTextSpotColor($name, $tint=100)
  72. // SetDrawSpotColor($name, $tint=100)
  73. // SetFillSpotColor($name, $tint=100)
  74. $pdf->SetTextSpotColor('My TCPDF Black', 100);
  75. $pdf->SetDrawSpotColor('My TCPDF Black', 100);
  76. $starty = 100;
  77. // print some spot colors
  78. $pdf->SetFillSpotColor('My TCPDF Dark Green', 100);
  79. $pdf->Rect(30, $starty, 40, 20, 'DF');
  80. $pdf->Text(73, $starty + 8, 'My TCPDF Dark Green');
  81. $starty += 24;
  82. $pdf->SetFillSpotColor('My TCPDF Light Yellow', 100);
  83. $pdf->Rect(30, $starty, 40, 20, 'DF');
  84. $pdf->Text(73, $starty + 8, 'My TCPDF Light Yellow');
  85. // --- default values defined on spotcolors.php ---
  86. $starty += 24;
  87. $pdf->SetFillSpotColor('My TCPDF Red', 100);
  88. $pdf->Rect(30, $starty, 40, 20, 'DF');
  89. $pdf->Text(73, $starty + 8, 'My TCPDF Red');
  90. $starty += 24;
  91. $pdf->SetFillSpotColor('My TCPDF Green', 100);
  92. $pdf->Rect(30, $starty, 40, 20, 'DF');
  93. $pdf->Text(73, $starty + 8, 'My TCPDF Green');
  94. $starty += 24;
  95. $pdf->SetFillSpotColor('My TCPDF Blue', 100);
  96. $pdf->Rect(30, $starty, 40, 20, 'DF');
  97. $pdf->Text(73, $starty + 8, 'My TCPDF Blue');
  98. $starty += 24;
  99. $pdf->SetFillSpotColor('My TCPDF Yellow', 100);
  100. $pdf->Rect(30, $starty, 40, 20, 'DF');
  101. $pdf->Text(73, $starty + 8, 'My TCPDF Yellow');
  102. // ---------------------------------------------------------
  103. //Close and output PDF document
  104. $pdf->Output('example_037.pdf', 'I');
  105. //============================================================+
  106. // END OF FILE
  107. //============================================================+