<?php
/**
 * Copyright 2004 by Gero Kohnert
 *
 * base format for TUTOS pdf output
 *
 *  CVS Info:  $Id: pdf.pinc,v 1.12 2005/01/17 05:11:26 saraj Exp $
 *  $Author: saraj $
 */

 if ($tutos[fpdfpath] != "") {
   if (!file_exists($tutos['base'] ."/". $tutos[fpdfpath].'/fpdf.php')) {
     die ("NO FPDF support. <br />\nSee \$tutos[fpdfpath] in config. <br />\nmissing:".$tutos['base'] ."/". $tutos[fpdfpath].'/fpdf.php');
   }
   include_once $tutos['base'] ."/". $tutos[fpdfpath].'/fpdf.php';
 } else {
   return;
 }

 class tutospdf extends FPDF {
   /**
    * Constructor
    */
   function tutospdf(&$dbconn)
   {
     global $tutos;

     $this->fpdf('P','mm',$tutos[paperformat]);
     $this->dbconn = &$dbconn;
     $this->AliasNbPages();
     $this->setCreator("TUTOS Version ".$tutos[version]);
     $this->setKeywords("TUTOS");
     $this->setDisplayMode('fullpage','continuous');
     $this->SetCompression(true);
     $this->SetAutoPageBreak(true,20);
  }
   //Page header
   function Header()
   {
     global $tutos;
     //Logo
     if (eregi("png",$this->dbconn->db->logo)) {
       @$this->Image($this->dbconn->db->logo,5,5,0,15,"PNG",$this->dbconn->db->logolink);
       $this->Cell(40);
     } else if (eregi("jpg",$this->dbconn->db->logo)) {
       @$this->Image($this->dbconn->db->logo,5,5,0,15,"JPG",$this->dbconn->db->logolink);
       $this->Cell(40);
     } else if (eregi("jpeg",$this->dbconn->db->logo)) {
       @$this->Image($this->dbconn->db->logo,5,5,0,15,"JPG",$this->dbconn->db->logolink);
       $this->Cell(40);
     }
     //Move to the right
     $this->SetY(5);
     //Title
     if (isset($this->headtitle)) {
       $this->SetFont('Arial','',15);
       $this->Cell(0,15,$this->headtitle,1,0,'C');
     }
     //Line break
     $this->Ln(20);
   }

   //Page footer
   function Footer()
   {
     global $lang,$tutos;

     $d = new DateTime();
     //Position at 1.5 cm from bottom
     //Arial italic 8
     $this->SetFont('Arial','I',8);
     $this->SetY(-15);
     $this->SetX(5);
     $this->Cell(0,10,$d->getDateTime(),0,0,'L');
     //Page number
     $this->SetX(5);
     $this->Cell(0,10,sprintf($lang['pageof'],$this->PageNo(),'{nb}'),0,0,'C');
     // LABEL
     $this->SetFont('Arial','',6);
     $this->SetX(5);
     $this->Cell(0,10,"generated by TUTOS ".$tutos[version],'T',1,'R',0,"http://www.tutos.org");
   }

 }
?>
