TCPDFBarcode::getBarcodeHTML PHP Method

getBarcodeHTML() public method

Return an HTML representation of barcode.
public getBarcodeHTML ( $w = 2, $h = 30, $color = 'black' ) : string
$w (int) Width of a single bar element in pixels.
$h (int) Height of a single bar element in pixels.
$color (string) Foreground color for bar elements (background is transparent).
return string HTML code.
    public function getBarcodeHTML($w = 2, $h = 30, $color = 'black')
    {
        $html = '<div style="font-size:0;position:relative;width:' . $this->barcode_array['maxw'] * $w . 'px;height:' . $h . 'px;">' . "\n";
        // print bars
        $x = 0;
        foreach ($this->barcode_array['bcode'] as $k => $v) {
            $bw = round($v['w'] * $w, 3);
            $bh = round($v['h'] * $h / $this->barcode_array['maxh'], 3);
            if ($v['t']) {
                $y = round($v['p'] * $h / $this->barcode_array['maxh'], 3);
                // draw a vertical bar
                $html .= '<div style="background-color:' . $color . ';width:' . $bw . 'px;height:' . $bh . 'px;position:absolute;left:' . $x . 'px;top:' . $y . 'px;">&nbsp;</div>' . "\n";
            }
            $x += $bw;
        }
        $html .= '</div>' . "\n";
        return $html;
    }

Usage Example

コード例 #1
0
ファイル: caisseController.php プロジェクト: jpainam/cosba
 /**
  * Impression d'un recu grace a l'operation caisse idcaisse
  * Afficher avant de proposer une impression
  * @param type $idcaisse
  */
 public function recu($idcaisse)
 {
     if (!isAuth(522)) {
         return;
     }
     $this->view->clientsJS("caisse" . DS . "recu");
     $view = new View();
     $operation = $this->Caisse->get($idcaisse);
     $view->Assign("operation", $operation);
     $this->loadBarcode(BARCODE_1);
     $barcodeobj = new TCPDFBarcode($operation['REFCAISSE'], 'C128A');
     $view->Assign("barcode", $barcodeobj->getBarcodeHTML(1, 35, 'black'));
     $personnel = $this->Personnel->getBy(["USER" => $this->session->iduser]);
     if (!empty($operation['PERCUPAR'])) {
         $percepteur = $this->Personnel->get($operation['PERCUPAR']);
         $view->Assign("percepteur", $percepteur);
     }
     if (!empty($operation['IMPRIMERPAR'])) {
         $imprimeur = $this->Personnel->get($operation['IMPRIMERPAR']);
     } else {
         $imprimeur = $personnel;
     }
     $percepteur = $this->Personnel->get($operation['PERCUPAR']);
     $view->Assign("percepteur", $percepteur);
     $enregistreur = $this->Personnel->get($operation['ENREGISTRERPAR']);
     $view->Assign("enregistreur", $enregistreur);
     $view->Assign("imprimeur", $imprimeur);
     $view->Assign("estDirectrice", $this->session->idprofile === DIRECTOR_PROFILE ? true : false);
     $classe = $this->Eleve->getClasse($operation['ELEVE'], $this->session->anneeacademique);
     $view->Assign("classe", $classe);
     $montantapayer = $this->Frais->getClasseTotalFrais($classe['IDCLASSE']);
     $view->Assign("montantapayer", $montantapayer);
     $montantpayer = $this->Caisse->getMontantPayer($operation['ELEVE']);
     $view->Assign("montantpayer", $montantpayer);
     $content = $view->Render("caisse" . DS . "recu", false);
     $this->Assign("content", $content);
 }
All Usage Examples Of TCPDFBarcode::getBarcodeHTML