printPDF.tpl.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. global $langs;
  3. $author = 'Big Bus Hungary Kft.';
  4. $PDFTitle = $langs->trans('HandoverProtocol');
  5. $PDFSubject = 'Subject';
  6. class MYPDF extends TCPDF {
  7. //Page header
  8. public function Header() {
  9. global $PDFTitle;
  10. // Logo
  11. //$image_file = K_PATH_IMAGES.'logo_example.jpg';
  12. //$this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
  13. // Set font
  14. $this->SetFont('helvetica', 'B', 20);
  15. // Title
  16. $this->Cell(0, 15, $PDFTitle, 0, false, 'C', 0, '', 0, false, 'M', 'M');
  17. }
  18. // Page footer
  19. public function Footer() {
  20. // Position at 15 mm from bottom
  21. $this->SetY(-15);
  22. // Set font
  23. $this->SetFont('helvetica', 'I', 8);
  24. // Page number
  25. $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
  26. }
  27. }
  28. $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  29. // set document information
  30. $pdf->SetCreator(PDF_CREATOR);
  31. $pdf->SetAuthor($author);
  32. $pdf->SetTitle($PDFTitle);
  33. $pdf->SetSubject($PDFSubject);
  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, PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
  37. $pdf->setFooterData(array(0,64,0), array(0,64,128));
  38. // set header and footer fonts
  39. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  40. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  41. // set default monospaced font
  42. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  43. // set margins
  44. $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  45. $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  46. $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  47. // set auto page breaks
  48. $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  49. // set image scale factor
  50. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  51. // set some language-dependent strings (optional)
  52. if (@file_exists(dirname(__FILE__).'/lang/hun.php')) {
  53. require_once(dirname(__FILE__).'/lang/hun.php');
  54. $pdf->setLanguageArray($l);
  55. }
  56. $pdf->setFontSubsetting(true);
  57. $pdf->SetFont('dejavusans', '', 14, '', true);
  58. $pdf->AddPage();
  59. $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
  60. //$html = $toolsOfGroups[0]['ref'];
  61. $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
  62. $pdf->Output($PDFTitle.'.pdf', 'I');
  63. //============================================================+
  64. // END OF FILE
  65. //============================================================+