Advertisement
Guest User

falei

a guest
Oct 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.33 KB | None | 0 0
  1. <?php
  2. //============================================================+
  3. // File name   : example_006.php
  4. // Begin       : 2008-03-04
  5. // Last Update : 2013-05-14
  6. //
  7. // Description : Example 006 for TCPDF class
  8. //               WriteHTML and RTL support
  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. /**
  20.  * Creates an example PDF TEST document using TCPDF
  21.  * @package com.tecnick.tcpdf
  22.  * @abstract TCPDF -   Example: WriteHTML and RTL support
  23.  * @author Nicola Asuni
  24.  * @since 2008-03-04
  25.  */
  26.  
  27. // Include the main TCPDF library (search for installation path).
  28. require_once('tcpdf.php');
  29.  
  30. class MYPDF extends TCPDF {
  31.     public function Header() {
  32.         // Logo
  33.         $image_file = K_PATH_IMAGES.'logo_example.jpg';
  34.                 $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, 'R', false, false, 0, false, false, false);
  35.         // Set font
  36.         $this->SetFont('helvetica', 'B', 20);
  37.         // Title
  38.     }
  39.  
  40.     public function Footer() {
  41.         // Position at 15 mm from bottom
  42.         $this->SetY(-15);
  43.         // Set font
  44.         $this->SetFont('helvetica', 'r', 7);
  45.         // Page number
  46.         $html = '<hr>';
  47.         // output the HTML content
  48.         $this->writeHTML($html, true, false, true, false, '');
  49.         $this->Cell(0, 0, 'lstdecalr', 0, false, 'R', 0, '', 0, false, 'T', 'M');
  50. }
  51. }
  52.  
  53. // create new PDF document
  54. $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  55.  
  56. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  57.  
  58. // set default monospaced font
  59. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  60.  
  61. // set margins
  62. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  63. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  64.  
  65. // set auto page breaks
  66. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  67.  
  68. // set image scale factor
  69. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  70.  
  71. // set some language-dependent strings (optional)
  72. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  73.     require_once(dirname(__FILE__).'/lang/eng.php');
  74.     $pdf->setLanguageArray($l);
  75. }
  76.  
  77. // ---------------------------------------------------------
  78.  
  79. // set font
  80. $pdf->SetFont('dejavusans', '', 10);
  81.  
  82. // add a page
  83. $pdf->AddPage();
  84.  
  85. $html = '<br><hr>';
  86.  
  87.  
  88. $left_column = '<font size="15" face="Verdana"><b>Universidade de Brasilia</b><br>
  89. <b><font size="13" face="Verdana">Comprovante de Matrícula 2016/2</b><br></font>
  90. <b><font size="5">Validade: 2016/2</b><br></font>
  91.  
  92. <br><font size="11"><b>Curso</b><br>
  93. Pedagogia<br>
  94. <b>Nome do Aluno</b><br>
  95. Evelyn Luíza Dias Figuereido<br>
  96. <b>Matrícula</b><br>
  97. 14/0138081<br></font>';
  98. $right_column = '<br><br>
  99. <b><font size="6">*** VÁLIDO SOMENTE COM CARIMBO NO VERSO ***</b><br>
  100. <b><font size="6">*** E APRESENTAÇÃO DA IDENTIDADE ESTUDANTIL ***</b><br></font>';
  101. $right_column1 ='
  102. <font size="11"><b>Turno</b><br>
  103. Diurno<br></font>';
  104. $y = $pdf->getY();
  105. $pdf->SetFont('times', '', 8);
  106. $pdf->SetFillColor(255, 255, 255);
  107. $pdf->SetTextColor(0, 0, 0);
  108. $pdf->writeHTMLCell(80, '', '', $y, $left_column, 0, 0, 0, true, 'L', true);
  109. $html = '<br>';
  110. // output the HTML content
  111. $pdf->writeHTML($html, false, false,TRUE, false);
  112. $pdf->writeHTMLCell(90, 20, 20,38, $right_column, 0, 0, 0, true, 'R', true);
  113. $pdf->writeHTMLCell(90, 20, 10,73, $right_column1, 0, 0, 0, true, 'R', true);
  114.  
  115. $pdf->writeHTMLCell(100, 30, 13, 26, '', 1, 1, 1, true, 'B', true);
  116. $pdf->writeHTMLCell(100, 50, 13, 49, '', 1, 1, 1, true, 'B', true);
  117. $pdf->writeHTMLCell(98, 32, 14, 50, '', 1, 1, 1, true, 'B', true);
  118. // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
  119. // define barcode style
  120.  
  121. // create some HTML content
  122.  
  123. $image_file = K_PATH_IMAGES.'12.png';
  124.  
  125.         $pdf->Image($image_file, 50, 86, 50,'', 'PNG', 6, 'B', false, 65,300, false, false, 0, false, false, false);
  126. // output some RTL HTML content
  127.  
  128.  
  129.  
  130. // test some inline CSS
  131.  
  132. // ---------------------------------------------------------
  133.  
  134. //Close and output PDF document
  135. $pdf->Output('example_006.pdf', 'I');
  136.  
  137. //============================================================+
  138. // END OF FILE
  139. //============================================================+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement