[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/includes/fpdf/ -> fpdf_html.php (source)

   1  <?php
   2  /* Modifié par Rodolphe Quiédeville
   3   * Auteur : Olivier PLATHEY
   4   * Source : http://www.fpdf.org
   5   * License:  Freeware
   6   * $Id: fpdf_html.php,v 1.1 2004/02/29 14:32:04 rodolphe Exp $
   7   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/fpdf/fpdf_html.php,v $
   8   */
   9  
  10  class PDF_html extends PDF_Indexes
  11  {
  12    var $B;
  13    var $I;
  14    var $U;
  15    var $HREF;
  16  
  17    function PDF_html($orientation='P',$unit='mm',$format='A4')
  18    {
  19      //Appel au constructeur parent
  20      $this->FPDF($orientation,$unit,$format);
  21      //Initialisation
  22      $this->B=0;
  23      $this->I=0;
  24      $this->U=0;
  25      $this->HREF='';
  26    }
  27  
  28    function WriteHTML($html)
  29    {
  30      //Parseur HTML
  31      $html=str_replace("\n",' ',$html);
  32      $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
  33      foreach($a as $i=>$e)
  34        {
  35          if($i%2==0)
  36        {
  37              //Texte
  38              if($this->HREF)
  39            $this->PutLink($this->HREF,$e);
  40              else
  41            $this->Write(5,$e);
  42        }
  43          else
  44        {
  45              //Balise
  46              if($e{0}=='/')
  47            $this->CloseTag(strtoupper(substr($e,1)));
  48              else
  49            {
  50                  //Extraction des attributs
  51                  $a2=explode(' ',$e);
  52                  $tag=strtoupper(array_shift($a2));
  53                  $attr=array();
  54                  foreach($a2 as $v)
  55            if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
  56              $attr[strtoupper($a3[1])]=$a3[2];
  57                  $this->OpenTag($tag,$attr);
  58            }
  59        }
  60        }
  61    }
  62    
  63    function OpenTag($tag,$attr)
  64    {
  65      //Balise ouvrante
  66      if($tag=='B' or $tag=='I' or $tag=='U')
  67        $this->SetStyle($tag,true);
  68      if($tag=='A')
  69        $this->HREF=$attr['HREF'];
  70      if($tag=='BR')
  71        $this->Ln(5);
  72    }
  73    
  74    function CloseTag($tag)
  75    {
  76      //Balise fermante
  77      if($tag=='B' or $tag=='I' or $tag=='U')
  78        $this->SetStyle($tag,false);
  79      if($tag=='A')
  80        $this->HREF='';
  81    }
  82    
  83    function SetStyle($tag,$enable)
  84    {
  85      //Modifie le style et sélectionne la police correspondante
  86      $this->$tag+=($enable ? 1 : -1);
  87      $style='';
  88      foreach(array('B','I','U') as $s)
  89        if($this->$s>0)
  90      $style.=$s;
  91      $this->SetFont('',$style);
  92    }
  93    
  94    function PutLink($URL,$txt)
  95    {
  96      //Place un hyperlien
  97      $this->SetTextColor(0,0,255);
  98      $this->SetStyle('U',true);
  99      $this->Write(5,$txt,$URL);
 100      $this->SetStyle('U',false);
 101      $this->SetTextColor(0);
 102    }
 103  }
 104  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics