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.

133 lines
4.3 KiB

  1. <?php
  2. //============================================================+
  3. // File name : example_056.php
  4. // Begin : 2010-03-26
  5. // Last Update : 2013-09-30
  6. //
  7. // Description : Example 056 for TCPDF class
  8. // Crop marks and color registration bars
  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: Crop marks and color registration bars
  22. * @author Nicola Asuni
  23. * @since 2010-03-26
  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 056');
  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.' 056', 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', '', 18);
  58. // add a page
  59. $pdf->AddPage();
  60. $pdf->Write(0, 'Example of Registration Marks, Crop Marks and Color Bars', '', 0, 'L', true, 0, false, false, 0);
  61. $pdf->Ln(5);
  62. // color registration bars
  63. // A,W,R,G,B,C,M,Y,K,RGB,CMYK,ALL,ALLSPOT,<SPOT_COLOR_NAME>
  64. $pdf->colorRegistrationBar(50, 70, 40, 40, true, false, 'A,R,G,B,C,M,Y,K');
  65. $pdf->colorRegistrationBar(90, 70, 40, 40, true, true, 'A,R,G,B,C,M,Y,K');
  66. $pdf->colorRegistrationBar(50, 115, 80, 5, false, true, 'A,W,R,G,B,C,M,Y,K,ALL');
  67. $pdf->colorRegistrationBar(135, 70, 5, 50, false, false, 'A,W,R,G,B,C,M,Y,K,ALL');
  68. // corner crop marks
  69. $pdf->cropMark(50, 70, 10, 10, 'TL');
  70. $pdf->cropMark(140, 70, 10, 10, 'TR');
  71. $pdf->cropMark(50, 120, 10, 10, 'BL');
  72. $pdf->cropMark(140, 120, 10, 10, 'BR');
  73. // various crop marks
  74. $pdf->cropMark(95, 65, 5, 5, 'LEFT,TOP,RIGHT', array(255,0,0));
  75. $pdf->cropMark(95, 125, 5, 5, 'LEFT,BOTTOM,RIGHT', array(255,0,0));
  76. $pdf->cropMark(45, 95, 5, 5, 'TL,BL', array(0,255,0));
  77. $pdf->cropMark(145, 95, 5, 5, 'TR,BR', array(0,255,0));
  78. $pdf->cropMark(95, 140, 5, 5, 'A,D', array(0,0,255));
  79. // registration marks
  80. $pdf->registrationMark(40, 60, 5, false);
  81. $pdf->registrationMark(150, 60, 5, true, array(0,0,0), array(255,255,0));
  82. $pdf->registrationMark(40, 130, 5, true, array(0,0,0), array(255,255,0));
  83. $pdf->registrationMark(150, 130, 5, false, array(100,100,100,100,'All'), array(0,0,0,0,'None'));
  84. // test registration bar with spot colors
  85. $pdf->AddSpotColor('My TCPDF Dark Green', 100, 50, 80, 45);
  86. $pdf->AddSpotColor('My TCPDF Light Yellow', 0, 0, 55, 0);
  87. $pdf->AddSpotColor('My TCPDF Black', 0, 0, 0, 100);
  88. $pdf->AddSpotColor('My TCPDF Red', 30, 100, 90, 10);
  89. $pdf->AddSpotColor('My TCPDF Green', 100, 30, 100, 0);
  90. $pdf->AddSpotColor('My TCPDF Blue', 100, 60, 10, 5);
  91. $pdf->AddSpotColor('My TCPDF Yellow', 0, 20, 100, 0);
  92. $pdf->colorRegistrationBar(50, 150, 80, 10, false, true, 'ALLSPOT');
  93. // CMYK registration mark
  94. $pdf->registrationMarkCMYK(150, 155, 8);
  95. // ---------------------------------------------------------
  96. //Close and output PDF document
  97. $pdf->Output('example_056.pdf', 'I');
  98. //============================================================+
  99. // END OF FILE
  100. //============================================================+