[ 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/i25/ -> i25.php (source)

   1  <?php
   2  require_once(FPDF_PATH.'fpdf.php');
   3  
   4  // based on the Code 39 script from The-eh

   5  class PDF_i25 extends FPDF
   6  {
   7  function i25($xpos, $ypos, $code, $basewidth=1, $height=10){
   8  
   9      $wide = $basewidth;
  10      $narrow = $basewidth / 3 ;
  11  
  12      // wide/narrow codes for the digits

  13      $barChar['0'] = 'nnwwn';
  14      $barChar['1'] = 'wnnnw';
  15      $barChar['2'] = 'nwnnw';
  16      $barChar['3'] = 'wwnnn';
  17      $barChar['4'] = 'nnwnw';
  18      $barChar['5'] = 'wnwnn';
  19      $barChar['6'] = 'nwwnn';
  20      $barChar['7'] = 'nnnww';
  21      $barChar['8'] = 'wnnwn';
  22      $barChar['9'] = 'nwnwn';
  23      $barChar['A'] = 'nn';
  24      $barChar['Z'] = 'wn';
  25  
  26      // add leading zero if code-length is odd

  27      if(strlen($code) % 2 != 0){
  28          $code = '0' . $code;
  29      }
  30  
  31      $this->SetFont('Arial','',10);
  32      $this->Text($xpos, $ypos + $height + 4, $code);
  33      $this->SetFillColor(0);
  34  
  35      // add start and stop codes

  36      $code = 'AA'.strtolower($code).'ZA';
  37  
  38      for($i=0; $i<strlen($code); $i=$i+2){
  39          // choose next pair of digits

  40          $charBar = $code{$i};
  41          $charSpace = $code{$i+1};
  42          // check whether it is a valid digit

  43          if(!isset($barChar[$charBar])){
  44              $this->Error('Invalid character in barcode: '.$charBar);
  45          }
  46          if(!isset($barChar[$charSpace])){
  47              $this->Error('Invalid character in barcode: '.$charSpace);
  48          }
  49          // create a wide/narrow-sequence (first digit=bars, second digit=spaces)

  50          $seq = '';
  51          for($s=0; $s<strlen($barChar[$charBar]); $s++){
  52              $seq .= $barChar[$charBar]{$s} . $barChar[$charSpace]{$s};
  53          }
  54          for($bar=0; $bar<strlen($seq); $bar++){
  55              // set lineWidth depending on value

  56              if($seq{$bar} == 'n'){
  57                  $lineWidth = $narrow;
  58              }else{
  59                  $lineWidth = $wide;
  60              }
  61              // draw every second value, because the second digit of the pair is represented by the spaces

  62              if($bar % 2 == 0){
  63                  $this->Rect($xpos, $ypos, $lineWidth, $height, 'F');
  64              }
  65              $xpos += $lineWidth;
  66          }
  67      }
  68  }
  69  }
  70  
  71  ?>


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