Created
October 15, 2019 22:57
-
-
Save govaniso/8345d73f30cabb3fe311a00394eae828 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* Description of codigo_barras_controller | |
* | |
* @author govani | |
*/ | |
Load::lib("tcpdf/tcpdf"); | |
class CodigoBarrasController extends AppController { | |
//put your code here | |
public function index() { | |
//https://tcpdf.org/examples/ | |
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); | |
$pdf->SetCreator(PDF_CREATOR); | |
$pdf->SetAuthor('Nicola Asuni'); | |
$pdf->SetTitle('TCPDF Example 050'); | |
$pdf->SetSubject('TCPDF Tutorial'); | |
$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); | |
$pdf->SetFont('helvetica', '', 11); | |
$pdf->AddPage(); | |
$txt = "https://tcpdf.org/examples/"; | |
//($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0, $valign='T', $fitcell=false) { | |
$pdf->MultiCell(70, 15, $txt, 1, 'J', false, 1, 125, 30, true, 0, false, true, 0, 'T', false); | |
$code = '111011101110111,010010001000010,010011001110010,010010000010010,010011101110010'; | |
$pdf->write2DBarcode($code, 'RAW', 80, 30, 30, 20, $style, 'N'); | |
$pdf->write2DBarcode('http://www.tcpdf.org', 'DATAMATRIX', 80, 70, 50, 50, $style, 'N'); | |
// define barcode style | |
$style = array( | |
'position' => '', | |
'align' => 'C', | |
'stretch' => false, | |
'fitwidth' => true, | |
'cellfitalign' => '', | |
'border' => false, | |
'hpadding' => 'auto', | |
'vpadding' => 'auto', | |
'fgcolor' => array(0, 0, 0), | |
'bgcolor' => false, //array(255,255,255), | |
'text' => true, | |
'font' => 'helvetica', | |
'fontsize' => 8, | |
'stretchtext' => 4 | |
); | |
// PRINT VARIOUS 1D BARCODES | |
// CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. | |
$pdf->Cell(0, 0, 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9', 0, 1); | |
$pdf->Ln(); | |
$pdf->write1DBarcode('123654987', 'C128', '', '', '', 18, 0.4, $style, 'N'); | |
$pdf->Output('ejemplo_etiquetas.pdf', 'I'); | |
View::select(null, null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment