example_028.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. //============================================================+
  3. // File name : example_028.php
  4. // Begin : 2008-03-04
  5. // Last Update : 2013-05-14
  6. //
  7. // Description : Example 028 for TCPDF class
  8. // Changing page formats
  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: changing page formats
  22. * @author Nicola Asuni
  23. * @since 2008-03-04
  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 028');
  33. $pdf->SetSubject('TCPDF Tutorial');
  34. $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  35. // remove default header/footer
  36. $pdf->setPrintHeader(false);
  37. $pdf->setPrintFooter(false);
  38. // set default monospaced font
  39. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  40. // set margins
  41. $pdf->SetMargins(10, PDF_MARGIN_TOP, 10);
  42. // set auto page breaks
  43. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  44. // set image scale factor
  45. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  46. // set some language-dependent strings (optional)
  47. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  48. require_once(dirname(__FILE__).'/lang/eng.php');
  49. $pdf->setLanguageArray($l);
  50. }
  51. // ---------------------------------------------------------
  52. $pdf->SetDisplayMode('fullpage', 'SinglePage', 'UseNone');
  53. // set font
  54. $pdf->SetFont('times', 'B', 20);
  55. $pdf->AddPage('P', 'A4');
  56. $pdf->Cell(0, 0, 'A4 PORTRAIT', 1, 1, 'C');
  57. $pdf->AddPage('L', 'A4');
  58. $pdf->Cell(0, 0, 'A4 LANDSCAPE', 1, 1, 'C');
  59. $pdf->AddPage('P', 'A5');
  60. $pdf->Cell(0, 0, 'A5 PORTRAIT', 1, 1, 'C');
  61. $pdf->AddPage('L', 'A5');
  62. $pdf->Cell(0, 0, 'A5 LANDSCAPE', 1, 1, 'C');
  63. $pdf->AddPage('P', 'A6');
  64. $pdf->Cell(0, 0, 'A6 PORTRAIT', 1, 1, 'C');
  65. $pdf->AddPage('L', 'A6');
  66. $pdf->Cell(0, 0, 'A6 LANDSCAPE', 1, 1, 'C');
  67. $pdf->AddPage('P', 'A7');
  68. $pdf->Cell(0, 0, 'A7 PORTRAIT', 1, 1, 'C');
  69. $pdf->AddPage('L', 'A7');
  70. $pdf->Cell(0, 0, 'A7 LANDSCAPE', 1, 1, 'C');
  71. // --- test backward editing ---
  72. $pdf->setPage(1, true);
  73. $pdf->SetY(50);
  74. $pdf->Cell(0, 0, 'A4 test', 1, 1, 'C');
  75. $pdf->setPage(2, true);
  76. $pdf->SetY(50);
  77. $pdf->Cell(0, 0, 'A4 test', 1, 1, 'C');
  78. $pdf->setPage(3, true);
  79. $pdf->SetY(50);
  80. $pdf->Cell(0, 0, 'A5 test', 1, 1, 'C');
  81. $pdf->setPage(4, true);
  82. $pdf->SetY(50);
  83. $pdf->Cell(0, 0, 'A5 test', 1, 1, 'C');
  84. $pdf->setPage(5, true);
  85. $pdf->SetY(50);
  86. $pdf->Cell(0, 0, 'A6 test', 1, 1, 'C');
  87. $pdf->setPage(6, true);
  88. $pdf->SetY(50);
  89. $pdf->Cell(0, 0, 'A6 test', 1, 1, 'C');
  90. $pdf->setPage(7, true);
  91. $pdf->SetY(40);
  92. $pdf->Cell(0, 0, 'A7 test', 1, 1, 'C');
  93. $pdf->setPage(8, true);
  94. $pdf->SetY(40);
  95. $pdf->Cell(0, 0, 'A7 test', 1, 1, 'C');
  96. $pdf->lastPage();
  97. // ---------------------------------------------------------
  98. //Close and output PDF document
  99. $pdf->Output('example_028.pdf', 'I');
  100. //============================================================+
  101. // END OF FILE
  102. //============================================================+