example_002.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. //============================================================+
  3. // File name : example_002.php
  4. // Begin : 2008-03-04
  5. // Last Update : 2013-05-14
  6. //
  7. // Description : Example 002 for TCPDF class
  8. // Removing Header and Footer
  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: Removing Header and Footer
  22. * @author Nicola Asuni
  23. * @since 2008-03-04
  24. * @group header
  25. * @group footer
  26. * @group page
  27. * @group pdf
  28. */
  29. // Include the main TCPDF library (search for installation path).
  30. require_once('tcpdf_include.php');
  31. // create new PDF document
  32. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  33. // set document information
  34. $pdf->setCreator(PDF_CREATOR);
  35. $pdf->setAuthor('Nicola Asuni');
  36. $pdf->setTitle('TCPDF Example 002');
  37. $pdf->setSubject('TCPDF Tutorial');
  38. $pdf->setKeywords('TCPDF, PDF, example, test, guide');
  39. // remove default header/footer
  40. $pdf->setPrintHeader(false);
  41. $pdf->setPrintFooter(false);
  42. // set default monospaced font
  43. $pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  44. // set margins
  45. $pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  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('times', 'BI', 20);
  58. // add a page
  59. $pdf->AddPage();
  60. // set some text to print
  61. $txt = <<<EOD
  62. TCPDF Example 002
  63. Default page header and footer are disabled using setPrintHeader() and setPrintFooter() methods.
  64. EOD;
  65. // print a block of text using Write()
  66. $pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
  67. // ---------------------------------------------------------
  68. //Close and output PDF document
  69. $pdf->Output('example_002.pdf', 'I');
  70. //============================================================+
  71. // END OF FILE
  72. //============================================================+