example_028.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. //============================================================+
  3. // File name : example_028.php
  4. // Begin : 2008-03-04
  5. // Last Update : 2010-08-08
  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 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: changing page formats
  25. * @author Nicola Asuni
  26. * @since 2008-03-04
  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 028');
  36. $pdf->SetSubject('TCPDF Tutorial');
  37. $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  38. // remove default header/footer
  39. $pdf->setPrintHeader(false);
  40. $pdf->setPrintFooter(false);
  41. // set default monospaced font
  42. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  43. //set margins
  44. $pdf->SetMargins(10, PDF_MARGIN_TOP, 10);
  45. //set auto page breaks
  46. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  47. //set image scale factor
  48. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  49. //set some language-dependent strings
  50. $pdf->setLanguageArray($l);
  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. //============================================================+