コード例 #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);
 }
コード例 #2
0
ファイル: tcpdf.php プロジェクト: TheTypoMaster/myapps
 /**
  * Print a Linear Barcode.
  * @param $code (string) code to print
  * @param $type (string) type of barcode (see tcpdf_barcodes_1d.php for supported formats).
  * @param $x (int) x position in user units (empty string = current x position)
  * @param $y (int) y position in user units (empty string = current y position)
  * @param $w (int) width in user units (empty string = remaining page width)
  * @param $h (int) height in user units (empty string = remaining page height)
  * @param $xres (float) width of the smallest bar in user units (empty string = default value = 0.4mm)
  * @param $style (array) array of options:<ul>
  * <li>boolean $style['border'] if true prints a border</li>
  * <li>int $style['padding'] padding to leave around the barcode in user units (set to 'auto' for automatic padding)</li>
  * <li>int $style['hpadding'] horizontal padding in user units (set to 'auto' for automatic padding)</li>
  * <li>int $style['vpadding'] vertical padding in user units (set to 'auto' for automatic padding)</li>
  * <li>array $style['fgcolor'] color array for bars and text</li>
  * <li>mixed $style['bgcolor'] color array for background (set to false for transparent)</li>
  * <li>boolean $style['text'] if true prints text below the barcode</li>
  * <li>string $style['label'] override default label</li>
  * <li>string $style['font'] font name for text</li><li>int $style['fontsize'] font size for text</li>
  * <li>int $style['stretchtext']: 0 = disabled; 1 = horizontal scaling only if necessary; 2 = forced horizontal scaling; 3 = character spacing only if necessary; 4 = forced character spacing.</li>
  * <li>string $style['position'] horizontal position of the containing barcode cell on the page: L = left margin; C = center; R = right margin.</li>
  * <li>string $style['align'] horizontal position of the barcode on the containing rectangle: L = left; C = center; R = right.</li>
  * <li>string $style['stretch'] if true stretch the barcode to best fit the available width, otherwise uses $xres resolution for a single bar.</li>
  * <li>string $style['fitwidth'] if true reduce the width to fit the barcode width + padding. When this option is enabled the 'stretch' option is automatically disabled.</li>
  * <li>string $style['cellfitalign'] this option works only when 'fitwidth' is true and 'position' is unset or empty. Set the horizontal position of the containing barcode cell inside the specified rectangle: L = left; C = center; R = right.</li></ul>
  * @param $align (string) Indicates the alignment of the pointer next to barcode insertion relative to barcode height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
  * @author Nicola Asuni
  * @since 3.1.000 (2008-06-09)
  * @public
  */
 public function write1DBarcode($code, $type, $x = '', $y = '', $w = '', $h = '', $xres = '', $style = '', $align = '')
 {
     if (TCPDF_STATIC::empty_string(trim($code))) {
         return;
     }
     require_once dirname(__FILE__) . '/tcpdf_barcodes_1d.php';
     // save current graphic settings
     $gvars = $this->getGraphicVars();
     // create new barcode object
     $barcodeobj = new TCPDFBarcode($code, $type);
     $arrcode = $barcodeobj->getBarcodeArray();
     if ($arrcode === false or empty($arrcode) or $arrcode['maxw'] <= 0) {
         $this->Error('Error in 1D barcode string');
     }
     if ($arrcode['maxh'] <= 0) {
         $arrcode['maxh'] = 1;
     }
     // set default values
     if (!isset($style['position'])) {
         $style['position'] = '';
     } elseif ($style['position'] == 'S') {
         // keep this for backward compatibility
         $style['position'] = '';
         $style['stretch'] = true;
     }
     if (!isset($style['fitwidth'])) {
         if (!isset($style['stretch'])) {
             $style['fitwidth'] = true;
         } else {
             $style['fitwidth'] = false;
         }
     }
     if ($style['fitwidth']) {
         // disable stretch
         $style['stretch'] = false;
     }
     if (!isset($style['stretch'])) {
         if ($w === '' or $w <= 0) {
             $style['stretch'] = false;
         } else {
             $style['stretch'] = true;
         }
     }
     if (!isset($style['fgcolor'])) {
         $style['fgcolor'] = array(0, 0, 0);
         // default black
     }
     if (!isset($style['bgcolor'])) {
         $style['bgcolor'] = false;
         // default transparent
     }
     if (!isset($style['border'])) {
         $style['border'] = false;
     }
     $fontsize = 0;
     if (!isset($style['text'])) {
         $style['text'] = false;
     }
     if ($style['text'] and isset($style['font'])) {
         if (isset($style['fontsize'])) {
             $fontsize = $style['fontsize'];
         }
         $this->SetFont($style['font'], '', $fontsize);
     }
     if (!isset($style['stretchtext'])) {
         $style['stretchtext'] = 4;
     }
     if ($x === '') {
         $x = $this->x;
     }
     if ($y === '') {
         $y = $this->y;
     }
     // check page for no-write regions and adapt page margins if necessary
     list($x, $y) = $this->checkPageRegions($h, $x, $y);
     if ($w === '' or $w <= 0) {
         if ($this->rtl) {
             $w = $x - $this->lMargin;
         } else {
             $w = $this->w - $this->rMargin - $x;
         }
     }
     // padding
     if (!isset($style['padding'])) {
         $padding = 0;
     } elseif ($style['padding'] === 'auto') {
         $padding = 10 * ($w / ($arrcode['maxw'] + 20));
     } else {
         $padding = floatval($style['padding']);
     }
     // horizontal padding
     if (!isset($style['hpadding'])) {
         $hpadding = $padding;
     } elseif ($style['hpadding'] === 'auto') {
         $hpadding = 10 * ($w / ($arrcode['maxw'] + 20));
     } else {
         $hpadding = floatval($style['hpadding']);
     }
     // vertical padding
     if (!isset($style['vpadding'])) {
         $vpadding = $padding;
     } elseif ($style['vpadding'] === 'auto') {
         $vpadding = $hpadding / 2;
     } else {
         $vpadding = floatval($style['vpadding']);
     }
     // calculate xres (single bar width)
     $max_xres = ($w - 2 * $hpadding) / $arrcode['maxw'];
     if ($style['stretch']) {
         $xres = $max_xres;
     } else {
         if (TCPDF_STATIC::empty_string($xres)) {
             $xres = 0.141 * $this->k;
             // default bar width = 0.4 mm
         }
         if ($xres > $max_xres) {
             // correct xres to fit on $w
             $xres = $max_xres;
         }
         if (isset($style['padding']) and $style['padding'] === 'auto' or isset($style['hpadding']) and $style['hpadding'] === 'auto') {
             $hpadding = 10 * $xres;
             if (isset($style['vpadding']) and $style['vpadding'] === 'auto') {
                 $vpadding = $hpadding / 2;
             }
         }
     }
     if ($style['fitwidth']) {
         $wold = $w;
         $w = $arrcode['maxw'] * $xres + 2 * $hpadding;
         if (isset($style['cellfitalign'])) {
             switch ($style['cellfitalign']) {
                 case 'L':
                     if ($this->rtl) {
                         $x -= $wold - $w;
                     }
                     break;
                 case 'R':
                     if (!$this->rtl) {
                         $x += $wold - $w;
                     }
                     break;
                 case 'C':
                     if ($this->rtl) {
                         $x -= ($wold - $w) / 2;
                     } else {
                         $x += ($wold - $w) / 2;
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     $text_height = $this->cell_height_ratio * $fontsize / $this->k;
     // height
     if ($h === '' or $h <= 0) {
         // set default height
         $h = $arrcode['maxw'] * $xres / 3 + 2 * $vpadding + $text_height;
     }
     $barh = $h - $text_height - 2 * $vpadding;
     if ($barh <= 0) {
         // try to reduce font or padding to fit barcode on available height
         if ($text_height > $h) {
             $fontsize = $h * $this->k / (4 * $this->cell_height_ratio);
             $text_height = $this->cell_height_ratio * $fontsize / $this->k;
             $this->SetFont($style['font'], '', $fontsize);
         }
         if ($vpadding > 0) {
             $vpadding = ($h - $text_height) / 4;
         }
         $barh = $h - $text_height - 2 * $vpadding;
     }
     // fit the barcode on available space
     list($w, $h, $x, $y) = $this->fitBlock($w, $h, $x, $y, false);
     // set alignment
     $this->img_rb_y = $y + $h;
     // set alignment
     if ($this->rtl) {
         if ($style['position'] == 'L') {
             $xpos = $this->lMargin;
         } elseif ($style['position'] == 'C') {
             $xpos = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
         } elseif ($style['position'] == 'R') {
             $xpos = $this->w - $this->rMargin - $w;
         } else {
             $xpos = $x - $w;
         }
         $this->img_rb_x = $xpos;
     } else {
         if ($style['position'] == 'L') {
             $xpos = $this->lMargin;
         } elseif ($style['position'] == 'C') {
             $xpos = ($this->w + $this->lMargin - $this->rMargin - $w) / 2;
         } elseif ($style['position'] == 'R') {
             $xpos = $this->w - $this->rMargin - $w;
         } else {
             $xpos = $x;
         }
         $this->img_rb_x = $xpos + $w;
     }
     $xpos_rect = $xpos;
     if (!isset($style['align'])) {
         $style['align'] = 'C';
     }
     switch ($style['align']) {
         case 'L':
             $xpos = $xpos_rect + $hpadding;
             break;
         case 'R':
             $xpos = $xpos_rect + ($w - $arrcode['maxw'] * $xres) - $hpadding;
             break;
         case 'C':
         default:
             $xpos = $xpos_rect + ($w - $arrcode['maxw'] * $xres) / 2;
             break;
     }
     $xpos_text = $xpos;
     // barcode is always printed in LTR direction
     $tempRTL = $this->rtl;
     $this->rtl = false;
     // print background color
     if ($style['bgcolor']) {
         $this->Rect($xpos_rect, $y, $w, $h, $style['border'] ? 'DF' : 'F', '', $style['bgcolor']);
     } elseif ($style['border']) {
         $this->Rect($xpos_rect, $y, $w, $h, 'D');
     }
     // set foreground color
     $this->SetDrawColorArray($style['fgcolor']);
     $this->SetTextColorArray($style['fgcolor']);
     // print bars
     foreach ($arrcode['bcode'] as $k => $v) {
         $bw = $v['w'] * $xres;
         if ($v['t']) {
             // draw a vertical bar
             $ypos = $y + $vpadding + $v['p'] * $barh / $arrcode['maxh'];
             $this->Rect($xpos, $ypos, $bw, $v['h'] * $barh / $arrcode['maxh'], 'F', array(), $style['fgcolor']);
         }
         $xpos += $bw;
     }
     // print text
     if ($style['text']) {
         if (isset($style['label']) and !TCPDF_STATIC::empty_string($style['label'])) {
             $label = $style['label'];
         } else {
             $label = $code;
         }
         $txtwidth = $arrcode['maxw'] * $xres;
         if ($this->GetStringWidth($label) > $txtwidth) {
             $style['stretchtext'] = 2;
         }
         // print text
         $this->x = $xpos_text;
         $this->y = $y + $vpadding + $barh;
         $cellpadding = $this->cell_padding;
         $this->SetCellPadding(0);
         $this->Cell($txtwidth, '', $label, 0, 0, 'C', false, '', $style['stretchtext'], false, 'T', 'T');
         $this->cell_padding = $cellpadding;
     }
     // restore original direction
     $this->rtl = $tempRTL;
     // restore previous settings
     $this->setGraphicVars($gvars);
     // set pointer to align the next text/objects
     switch ($align) {
         case 'T':
             $this->y = $y;
             $this->x = $this->img_rb_x;
             break;
         case 'M':
             $this->y = $y + round($h / 2);
             $this->x = $this->img_rb_x;
             break;
         case 'B':
             $this->y = $this->img_rb_y;
             $this->x = $this->img_rb_x;
             break;
         case 'N':
             $this->SetY($this->img_rb_y);
             break;
         default:
             break;
     }
     $this->endlinex = $this->img_rb_x;
 }
コード例 #3
0
ファイル: tcpdf.php プロジェクト: retrofox/Huemul
 /**
  * Print a Linear Barcode.
  * @param string $code code to print
  * @param string $type type of barcode (see barcodes.php for supported formats).
  * @param int $x x position in user units
  * @param int $y y position in user units
  * @param int $w width in user units
  * @param int $h height in user units
  * @param float $xres width of the smallest bar in user units
  * @param array $style array of options:<ul><li>string $style['position'] barcode position inside the specified width: L = left (default for LTR); C = center; R = right (default for RTL); S = stretch</li><li>boolean $style['border'] if true prints a border around the barcode</li><li>int $style['padding'] padding to leave around the barcode in user units</li><li>array $style['fgcolor'] color array for bars and text</li><li>mixed $style['bgcolor'] color array for background or false for transparent</li><li>boolean $style["text"] boolean if true prints text below the barcode</li><li>string $style['font'] font name for text</li><li>int $style['fontsize'] font size for text</li><li>int $style['stretchtext']: 0 = disabled; 1 = horizontal scaling only if necessary; 2 = forced horizontal scaling; 3 = character spacing only if necessary; 4 = forced character spacing</li></ul>
  * @param string $align Indicates the alignment of the pointer next to barcode insertion relative to barcode height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
  * @author Nicola Asuni
  * @since 3.1.000 (2008-06-09)
  * @access public
  */
 public function write1DBarcode($code, $type, $x = '', $y = '', $w = '', $h = '', $xres = 0.4, $style = '', $align = '')
 {
     if ($this->empty_string($code)) {
         return;
     }
     require_once dirname(__FILE__) . '/barcodes.php';
     // save current graphic settings
     $gvars = $this->getGraphicVars();
     // create new barcode object
     $barcodeobj = new TCPDFBarcode($code, $type);
     $arrcode = $barcodeobj->getBarcodeArray();
     if ($arrcode === false) {
         $this->Error('Error in 1D barcode string');
     }
     // set default values
     if (!isset($style['position'])) {
         if ($this->rtl) {
             $style['position'] = 'R';
         } else {
             $style['position'] = 'L';
         }
     }
     if (!isset($style['padding'])) {
         $style['padding'] = 0;
     }
     if (!isset($style['fgcolor'])) {
         $style['fgcolor'] = array(0, 0, 0);
         // default black
     }
     if (!isset($style['bgcolor'])) {
         $style['bgcolor'] = false;
         // default transparent
     }
     if (!isset($style['border'])) {
         $style['border'] = false;
     }
     $fontsize = 0;
     if (!isset($style['text'])) {
         $style['text'] = false;
     }
     if ($style['text'] and isset($style['font'])) {
         if (isset($style['fontsize'])) {
             $fontsize = $style['fontsize'];
         }
         $this->SetFont($style['font'], '', $fontsize);
     }
     if (!isset($style['stretchtext'])) {
         $style['stretchtext'] = 4;
     }
     // set foreground color
     $this->SetDrawColorArray($style['fgcolor']);
     $this->SetTextColorArray($style['fgcolor']);
     if ($this->empty_string($w) or $w <= 0) {
         if ($this->rtl) {
             $w = $this->x - $this->lMargin;
         } else {
             $w = $this->w - $this->rMargin - $this->x;
         }
     }
     if ($this->empty_string($x)) {
         $x = $this->GetX();
     }
     if ($this->rtl) {
         $x = $this->w - $x;
     }
     if ($this->empty_string($y)) {
         $y = $this->GetY();
     }
     if ($this->empty_string($xres)) {
         $xres = 0.4;
     }
     $fbw = $arrcode['maxw'] * $xres + 2 * $style['padding'];
     $extraspace = $this->cell_height_ratio * $fontsize / $this->k + 2 * $style['padding'];
     if ($this->empty_string($h) or $h <= 0) {
         $h = 10 + $extraspace;
     }
     $prev_x = $this->x;
     if ($this->checkPageBreak($h, $y)) {
         $y = $this->GetY() + $this->cMargin;
         if ($this->rtl) {
             $x += $prev_x - $this->x;
         } else {
             $x += $this->x - $prev_x;
         }
     }
     // maximum bar height
     $barh = $h - $extraspace;
     switch ($style['position']) {
         case 'L':
             // left
             if ($this->rtl) {
                 $xpos = $x - $w;
             } else {
                 $xpos = $x;
             }
             break;
         case 'C':
             // center
             $xdiff = ($w - $fbw) / 2;
             if ($this->rtl) {
                 $xpos = $x - $w + $xdiff;
             } else {
                 $xpos = $x + $xdiff;
             }
             break;
         case 'R':
             // right
             if ($this->rtl) {
                 $xpos = $x - $fbw;
             } else {
                 $xpos = $x + $w - $fbw;
             }
             break;
         case 'S':
             // stretch
             $fbw = $w;
             $xres = ($w - 2 * $style['padding']) / $arrcode['maxw'];
             if ($this->rtl) {
                 $xpos = $x - $w;
             } else {
                 $xpos = $x;
             }
             break;
     }
     $xpos_rect = $xpos;
     $xpos = $xpos_rect + $style['padding'];
     $xpos_text = $xpos;
     // barcode is always printed in LTR direction
     $tempRTL = $this->rtl;
     $this->rtl = false;
     // print background color
     if ($style['bgcolor']) {
         $this->Rect($xpos_rect, $y, $fbw, $h, $style['border'] ? 'DF' : 'F', '', $style['bgcolor']);
     } elseif ($style['border']) {
         $this->Rect($xpos_rect, $y, $fbw, $h, 'D');
     }
     // print bars
     if ($arrcode !== false) {
         foreach ($arrcode['bcode'] as $k => $v) {
             $bw = $v['w'] * $xres;
             if ($v['t']) {
                 // draw a vertical bar
                 $ypos = $y + $style['padding'] + $v['p'] * $barh / $arrcode['maxh'];
                 $this->Rect($xpos, $ypos, $bw, $v['h'] * $barh / $arrcode['maxh'], 'F', array(), $style['fgcolor']);
             }
             $xpos += $bw;
         }
     }
     // print text
     if ($style['text']) {
         // print text
         $this->x = $xpos_text;
         $this->y = $y + $style['padding'] + $barh;
         $this->Cell($arrcode['maxw'] * $xres, $this->cell_height_ratio * $fontsize / $this->k, $code, 0, 0, 'C', 0, '', $style['stretchtext']);
     }
     // restore original direction
     $this->rtl = $tempRTL;
     // restore previous settings
     $this->setGraphicVars($gvars);
     // set bottomcoordinates
     $this->img_rb_y = $y + $h;
     if ($this->rtl) {
         // set left side coordinate
         $this->img_rb_x = $this->w - $x - $w;
     } else {
         // set right side coordinate
         $this->img_rb_x = $x + $w;
     }
     // set pointer to align the successive text/objects
     switch ($align) {
         case 'T':
             $this->y = $y;
             $this->x = $this->img_rb_x;
             break;
         case 'M':
             $this->y = $y + round($h / 2);
             $this->x = $this->img_rb_x;
             break;
         case 'B':
             $this->y = $this->img_rb_y;
             $this->x = $this->img_rb_x;
             break;
         case 'N':
             $this->SetY($this->img_rb_y);
             break;
         default:
             break;
     }
 }
コード例 #4
0
ファイル: Event.php プロジェクト: openeyes/openeyes
 public function getBarCodeHTML()
 {
     $barcode = new TCPDFBarcode("E:{$this->id}", 'C128');
     return $barcode->getBarcodeHTML(1, 8);
 }
コード例 #5
0
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with TCPDF.  If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_1d.php class
//
//============================================================+
/**
 * @file
 * Example for tcpdf_barcodes_1d.php class
 * @package com.tecnick.tcpdf
 * @author Nicola Asuni
 * @version 1.0.000
 */
// include 1D barcode class
require_once dirname(__FILE__) . '/../../tcpdf_barcodes_1d.php';
// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');
// output the barcode as HTML object
echo $barcodeobj->getBarcodeHTML(2, 30, 'black');
//============================================================+
// END OF FILE
//============================================================+
コード例 #6
0
ファイル: example_1d_svgi.php プロジェクト: ade24/vcorner
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with TCPDF.  If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_1d.php class
//
//============================================================+
/**
 * @file
 * Example for tcpdf_barcodes_1d.php class
 * @package com.tecnick.tcpdf
 * @author Nicola Asuni
 * @version 1.0.000
 */
// include 1D barcode class
require_once dirname(__FILE__) . '/../../tcpdf_barcodes_1d.php';
// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');
// output the barcode as SVG inline code
echo $barcodeobj->getBarcodeSVGcode(2, 40, 'black');
//============================================================+
// END OF FILE
//============================================================+
コード例 #7
0
ファイル: tcpdf.php プロジェクト: jr-ewing/phpMyFAQ
 /**
  * Print a Linear Barcode.
  * @param string $code code to print
  * @param string $type type of barcode (see barcodes.php for supported formats).
  * @param int $x x position in user units
  * @param int $y y position in user units
  * @param int $w width in user units
  * @param int $h height in user units
  * @param float $xres width of the smallest bar in user units
  * @param array $style array of options:<ul><li>boolean $style['border'] if true prints a border around the barcode</li><li>int $style['padding'] padding to leave around the barcode in user units (set to 'auto' for automatic padding)</li><li>array $style['fgcolor'] color array for bars and text</li><li>mixed $style['bgcolor'] color array for background or false for transparent</li><li>boolean $style["text"] boolean if true prints text below the barcode</li><li>string $style['font'] font name for text</li><li>int $style['fontsize'] font size for text</li><li>int $style['stretchtext']: 0 = disabled; 1 = horizontal scaling only if necessary; 2 = forced horizontal scaling; 3 = character spacing only if necessary; 4 = forced character spacing</li><li>string $style['position'] barcode position on the page: L = left margin; C = center; R = right margin; S = stretch</li></ul>
  * @param string $align Indicates the alignment of the pointer next to barcode insertion relative to barcode height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
  * @author Nicola Asuni
  * @since 3.1.000 (2008-06-09)
  * @access public
  */
 public function write1DBarcode($code, $type, $x = '', $y = '', $w = '', $h = '', $xres = 0.4, $style = '', $align = '')
 {
     if ($this->empty_string(trim($code))) {
         return;
     }
     require_once dirname(__FILE__) . '/barcodes.php';
     // save current graphic settings
     $gvars = $this->getGraphicVars();
     // create new barcode object
     $barcodeobj = new TCPDFBarcode($code, $type);
     $arrcode = $barcodeobj->getBarcodeArray();
     if ($arrcode === false) {
         $this->Error('Error in 1D barcode string');
     }
     // set default values
     if (!isset($style['position'])) {
         $style['position'] = '';
     }
     if (!isset($style['fgcolor'])) {
         $style['fgcolor'] = array(0, 0, 0);
         // default black
     }
     if (!isset($style['bgcolor'])) {
         $style['bgcolor'] = false;
         // default transparent
     }
     if (!isset($style['border'])) {
         $style['border'] = false;
     }
     $fontsize = 0;
     if (!isset($style['text'])) {
         $style['text'] = false;
     }
     if ($style['text'] and isset($style['font'])) {
         if (isset($style['fontsize'])) {
             $fontsize = $style['fontsize'];
         }
         $this->SetFont($style['font'], '', $fontsize);
     }
     if (!isset($style['stretchtext'])) {
         $style['stretchtext'] = 4;
     }
     // set foreground color
     $this->SetDrawColorArray($style['fgcolor']);
     $this->SetTextColorArray($style['fgcolor']);
     if ($x === '') {
         $x = $this->x;
     }
     if ($y === '') {
         $y = $this->y;
     }
     if ($w === '' or $w <= 0) {
         if ($this->rtl) {
             $w = $this->x - $this->lMargin;
         } else {
             $w = $this->w - $this->rMargin - $this->x;
         }
     }
     if ($h === '' or $h <= 0) {
         // horizontal aspect ration by default
         $h = $w / 3;
     }
     if ($this->empty_string($xres)) {
         $xres = 0.4;
     }
     // padding
     if (!isset($style['padding'])) {
         $style['padding'] = 0;
     } elseif ($style['padding'] === 'auto') {
         $style['padding'] = $h / 4;
     }
     $fbw = $arrcode['maxw'] * $xres + 2 * $style['padding'];
     $extraspace = $this->cell_height_ratio * $fontsize / $this->k + 2 * $style['padding'];
     // maximum bar height
     $barh = $h;
     $h += $extraspace;
     // fit the barcode on available space
     $this->fitBlock($w, $h, $x, $y, false);
     // set alignment
     $this->img_rb_y = $y + $h;
     // set alignment
     if ($this->rtl) {
         if ($style['position'] == 'L') {
             $xpos = $this->lMargin;
         } elseif ($style['position'] == 'C') {
             $xpos = ($this->w + $this->lMargin - $this->rMargin - $fbw) / 2;
         } elseif ($style['position'] == 'R') {
             $xpos = $this->w - $this->rMargin - $fbw;
         } elseif ($style['position'] == 'S') {
             $fbw = $w;
             $xres = ($w - 2 * $style['padding']) / $arrcode['maxw'];
             $xpos = $x - $w;
         } else {
             $xpos = $x - $fbw;
         }
         $this->img_rb_x = $xpos;
     } else {
         if ($style['position'] == 'L') {
             $xpos = $this->lMargin;
         } elseif ($style['position'] == 'C') {
             $xpos = ($this->w + $this->lMargin - $this->rMargin - $fbw) / 2;
         } elseif ($style['position'] == 'R') {
             $xpos = $this->w - $this->rMargin - $fbw;
         } elseif ($style['position'] == 'S') {
             $fbw = $w;
             $xres = ($w - 2 * $style['padding']) / $arrcode['maxw'];
             $xpos = $x;
         } else {
             $xpos = $x;
         }
         $this->img_rb_x = $xpos + $fbw;
     }
     $xpos_rect = $xpos;
     $xpos = $xpos_rect + $style['padding'];
     $xpos_text = $xpos;
     // barcode is always printed in LTR direction
     $tempRTL = $this->rtl;
     $this->rtl = false;
     // print background color
     if ($style['bgcolor']) {
         $this->Rect($xpos_rect, $y, $fbw, $h, $style['border'] ? 'DF' : 'F', '', $style['bgcolor']);
     } elseif ($style['border']) {
         $this->Rect($xpos_rect, $y, $fbw, $h, 'D');
     }
     // print bars
     foreach ($arrcode['bcode'] as $k => $v) {
         $bw = $v['w'] * $xres;
         if ($v['t']) {
             // draw a vertical bar
             $ypos = $y + $style['padding'] + $v['p'] * $barh / $arrcode['maxh'];
             $this->Rect($xpos, $ypos, $bw, $v['h'] * $barh / $arrcode['maxh'], 'F', array(), $style['fgcolor']);
         }
         $xpos += $bw;
     }
     // print text
     if ($style['text']) {
         // print text
         $this->x = $xpos_text;
         $this->y = $y + $style['padding'] + $barh;
         $this->Cell($arrcode['maxw'] * $xres, $this->cell_height_ratio * $fontsize / $this->k, $code, 0, 0, 'C', 0, '', $style['stretchtext']);
     }
     // restore original direction
     $this->rtl = $tempRTL;
     // restore previous settings
     $this->setGraphicVars($gvars);
     // set pointer to align the successive text/objects
     switch ($align) {
         case 'T':
             $this->y = $y;
             $this->x = $this->img_rb_x;
             break;
         case 'M':
             $this->y = $y + round($h / 2);
             $this->x = $this->img_rb_x;
             break;
         case 'B':
             $this->y = $this->img_rb_y;
             $this->x = $this->img_rb_x;
             break;
         case 'N':
             $this->SetY($this->img_rb_y);
             break;
         default:
             break;
     }
     $this->endlinex = $this->img_rb_x;
 }
コード例 #8
0
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with TCPDF.  If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_2d.php class
//
//============================================================+
/**
 * @file
 * Example for tcpdf_barcodes_2d.php class
 * @package com.tecnick.tcpdf
 * @author Nicola Asuni
 * @version 1.0.000
 */
// include 1D barcode class (search for installation path)
require_once dirname(__FILE__) . '/tcpdf_barcodes_1d_include.php';
// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');
// output the barcode as PNG image
$barcodeobj->getBarcodePNG(2, 30, array(0, 0, 0));
//============================================================+
// END OF FILE
//============================================================+
コード例 #9
0
ファイル: example_1d_svg.php プロジェクト: ade24/vcorner
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with TCPDF.  If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Example for tcpdf_barcodes_1d.php class
//
//============================================================+
/**
 * @file
 * Example for tcpdf_barcodes_1d.php class
 * @package com.tecnick.tcpdf
 * @author Nicola Asuni
 * @version 1.0.000
 */
// include 1D barcode class
require_once dirname(__FILE__) . '/../../tcpdf_barcodes_1d.php';
// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');
// output the barcode as SVG image
$barcodeobj->getBarcodeSVG(2, 30, 'black');
//============================================================+
// END OF FILE
//============================================================+
コード例 #10
0
ファイル: Master.php プロジェクト: xepan/commerce
 function generatePDF($action = 'return')
 {
     if (!in_array($action, ['return', 'dump'])) {
         throw $this->exception('Please provide action as result or dump');
     }
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('xEpan ERP');
     $pdf->SetTitle($this['type'] . ' ' . $this['document_no']);
     $pdf->SetSubject($this['type'] . ' ' . $this['document_no']);
     $pdf->SetKeywords($this['type'] . ' ' . $this['document_no']);
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set font
     $pdf->SetFont('dejavusans', '', 10);
     //remove header or footer hr lines
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     // add a page
     $pdf->AddPage();
     if ($org = $this->ref('contact_id')->get('organization')) {
         $this['contact'] = $org;
         $this['contact_id'] = '';
     }
     // getting layouts from config
     $layout_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['master' => 'xepan\\base\\RichText', 'detail' => 'xepan\\base\\RichText'], 'config_key' => strtoupper($this['type']) . '_LAYOUT', 'application' => 'commerce']);
     $layout_m->tryLoadAny();
     $info_config = $layout_m['master'];
     $info_layout = $this->add('GiTemplate');
     $info_layout->loadTemplateFromString($info_config);
     $detail_config = $layout_m['detail'];
     $detail_layout = $this->add('GiTemplate');
     $detail_layout->loadTemplateFromString($detail_config);
     $new = $this->add('xepan\\commerce\\Model_QSP_Master');
     $new->addHook('afterLoad', function ($m) {
         $m['round_amount'] = abs($m['round_amount']);
     });
     $new->load($this->id);
     $view = $this->app->add('xepan\\commerce\\View_QSP', ['qsp_model' => $new, 'master_template' => $info_layout, 'detail_template' => $detail_layout, 'action' => 'pdf']);
     // $view = $this->owner->add('xepan\commerce\View_QSP',['qsp_model'=>$this]);
     if ($bar_code = $this->getBarCode()) {
         $barcodeobj = new \TCPDFBarcode($bar_code, 'C128');
         // $barcode_html = $barcodeobj->getBarcodePNG(2, 30, 'black');
         $barcode_html = $barcodeobj->getBarcodePngData(1, 20, array(0, 128, 0));
         $info_layout->trySetHtml('dispatch_barcode', '<img src="data:image/png;base64, ' . base64_encode($barcode_html) . '"/>');
     }
     $html = $view->getHTML();
     // echo "string".$html;
     // echo $html;
     // exit;
     // output the HTML content
     $pdf->writeHTML($html, false, false, true, false, '');
     // set default form properties
     $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128)));
     // reset pointer to the last page
     $pdf->lastPage();
     //Close and output PDF document
     switch ($action) {
         case 'return':
             return $pdf->Output(null, 'S');
             break;
         case 'dump':
             return $pdf->Output(null, 'I');
             exit;
             break;
     }
 }
コード例 #11
0
 /**
  *	Save an image file on disk (with no output)
  *
  *	@param	   string	    $code		      Value to encode
  *	@param	   string	    $encoding	      Mode of encoding
  *	@param	   string	    $readable	      Code can be read
  *	@param	   integer		$scale			  Scale (not used with this engine)
  *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
  *	@return	   int			                  <0 if KO, >0 if OK
  */
 function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
 {
     global $conf, $_GET;
     dol_mkdir($conf->barcode->dir_temp);
     $file = $conf->barcode->dir_temp . '/barcode_' . $code . '_' . $encoding . '.png';
     $tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
     if (empty($tcpdfEncoding)) {
         return -1;
     }
     $color = array(0, 0, 0);
     $_GET["code"] = $code;
     $_GET["type"] = $encoding;
     $_GET["height"] = $height;
     $_GET["readable"] = $readable;
     if ($code) {
         // Load the tcpdf barcode class
         if ($this->is2d) {
             $height = 1;
             $width = 1;
             require_once TCPDF_PATH . 'tcpdf_barcodes_2d.php';
             $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
         } else {
             $height = 50;
             $width = 1;
             require_once TCPDF_PATH . 'tcpdf_barcodes_1d.php';
             $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
         }
         dol_syslog("writeBarCode::TCPDF.getBarcodePngData");
         if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
             if (function_exists('imagecreate')) {
                 $imageData = imagecreatefromstring($imageData);
             }
             if (imagepng($imageData, $file)) {
                 return 1;
             } else {
                 return -3;
             }
         } else {
             return -4;
         }
     } else {
         return -2;
     }
 }
コード例 #12
0
ファイル: inbound_action.php プロジェクト: natcha23/wmstm
                     //echo $db->last_query();
                     if ($numRow == 0) {
                         $qty = $_POST['qty'][$key];
                         $sqlGetInbound = $db->get_where('inbound_po', 'inbound_id = ' . $key);
                         $rsGetInbound = $sqlGetInbound->row_array();
                         $data = array('pallet_id' => $updateID, 'po_id' => $rsGetInbound['po_id'], 'inbound_key' => $rsGetInbound['inbound_id'], 'supplier_id' => $rsGetInbound['po_supplier'], 'qty' => $qty, 'create_time' => _DATE_TIME_, 'user_id' => $user_id);
                         $db->insert('inbound_pallet_item', $data);
                     } else {
                         if ($numRow == 1) {
                             $qty = $_POST['qty'][$key] + $rsRow['qty'];
                             $data = array('qty' => $qty);
                             $db->update('inbound_pallet_item', $data, 'id =' . $rsRow['id']);
                         }
                     }
                     $barcode = str_pad($updateID, 10, "0", STR_PAD_LEFT);
                     $barcodeobj = new TCPDFBarcode($barcode, 'C128');
                     $showBarcode = $barcodeobj->getBarcodePNG(2, 30, array(0, 0, 0), $updateID);
                     $back['barcode'] = '
     <span class="detailBarcode" style="text-align: center; line-height:40px;font-size: 16px;float:right;">
         <span class="barcodeImg" style="margin-left:10px; margin-top:10px;">
             <img class="imgBarcode" src="data:image/png;base64,' . $showBarcode . '" style="" />
         </span>
     </span>
 ';
                     //echo $db->last_query();
                 }
                 $back['actionID'] = $updateID;
                 echo json_encode($back);
             } else {
                 if ($_POST['method'] == 'manage_pallet_success') {
                     $palletID = $_POST['palletID'];
コード例 #13
0
ファイル: pallet_manage.php プロジェクト: natcha23/wmstm
    ?>
</td>
                            <td>
                                <button onclick="$.managePallet(<?php 
    echo $arr['pallet_id'];
    ?>
)">จัดการ</button>
                            </td>
                        </tr>
                        <div id="barcode<?php 
    echo $arr['pallet_id'];
    ?>
" style="display: none;">
                            <?php 
    $barcode = str_pad($arr['pallet_id'], 10, "0", STR_PAD_LEFT);
    $barcodeobj = new TCPDFBarcode($barcode, 'C128');
    $showBarcode = $barcodeobj->getBarcodePNG(2, 30, array(0, 0, 0), $arr['pallet_id']);
    echo '
                                <span class="detailBarcode" style="text-align: center; line-height:40px;font-size: 16px;float:right;">
                                    <span class="barcodeImg" style="margin-left:10px; margin-top:10px;">
                                        <img class="imgBarcode" src="data:image/png;base64,' . $showBarcode . '" style="" />
                                    </span>
                                </span>
                            ';
    ?>
                        </div>
                <?php 
}
?>
                </tbody>
            </table>
コード例 #14
0
ファイル: Barcode1D.php プロジェクト: martinlindhe/core3
 protected function getPng($code, $type)
 {
     $barcode = new \TCPDFBarcode($code, $type);
     return $barcode->getBarcodePNGData(2, 30, array(0, 0, 0));
 }
コード例 #15
-1
ファイル: lab_config1.php プロジェクト: syafiqazwan/pharmaco
function getBarcode($sample)
{
    require "../tcpdf/tcpdf_barcodes_1d.php";
    if (!$sample) {
        echo "";
    } else {
        $barcodeobj = new TCPDFBarcode($sample, 'C128');
        echo $barcodeobj->getBarcodeHTML(2, 30, 'black');
    }
}