RE: [PHP-ES] Generar un PDF con un códig o de barras con los datos de un form en PHP
| From: | Pablo Prieto Sebastia | Date: | Wed, 18 Sep 2013 11:38:40 +0000 |
| Subject: | RE: [PHP-ES] Generar un PDF con un códig o de barras con los datos de un form en PHP | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-65571@lists.php.net to get a copy of this message | ||
Perdona, en la declaración de ImprovedTable($header,$data) debería ser ImprovedTable($header,$cb)
-----Mensaje original-----
De: Pablo Prieto Sebastia <pablo.prieto@dulcesol.es>
Enviado: Mier 18-09-2013 12:57
Para: ciracusa <ciracusa@gmail.com>;
CC: php-es@lists.php.net;
Asunto: RE: [PHP-ES] Generar un PDF con un código de barras con los datos de un form en PHP
> define('FPDF_FONTPATH','font/');
> require('fpdf/fpdf.php');
> include_once('php-barcode.php');
>
> class PDF extends FPDF {
> function TextWithRotation($x, $y, $txt, $txt_angle, $font_angle=0) {
> $font_angle+=90+$txt_angle;
> $txt_angle*=M_PI/180;
> $font_angle*=M_PI/180;
>
> $txt_dx=cos($txt_angle);
> $txt_dy=sin($txt_angle);
> $font_dx=cos($font_angle);
> $font_dy=sin($font_angle);
>
> $s=sprintf('BT %.2F %.2F %.2F %.2F %.2F %.2F Tm (%s) Tj
> ET',$txt_dx,$txt_dy,$font_dx,$font_dy,$x*$this->k,
> ($this->h-$y)*$this->k,$this->_escape($txt));
> if ($this->ColorFlag)
> $s='q '.$this->TextColor.' '.$s.' Q';
> $this->_out($s);
> } //Funcion TextWithRotation
>
> function ImprovedTable($header,$data) {
> //jugar con estas variables para el resultado deseado.
> $fontSize = 14;
> $marge = 0; // between barcode and hri in pixel
> $x = 150; // barcode center
> $y = 170; // barcode center
> $height = 30; // barcode height in 1D ; module size in 2D
> $width=0.3; // barcode height in 1D ; not use in 2D
> $angle = 0; // rotation in degrees : nb : non horizontable barcode might
> not be usable because of pixelisation
>
> $code = $cb; // barcode, of course ;)
> $type = 'ean13';
> $type='code39';
> $black = '000000'; // color in hexa
>
> $data = Barcode::fpdf($this, $black, $x, $y, $angle, $type,
> array('code'=>$code), $width, $height);
> // -------------------------------------------------- //
> // HRI
> // -------------------------------------------------- //
> $this->SetFont('Arial','B',$fontSize);
> $this->SetTextColor(0, 0, 0);
> $len = $this->GetStringWidth($data['hri']);
> Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge,
> $angle, $xt, $yt);
> $this->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
> } //Funcion ImprovedTable
> } Class
>
> //Prog. principal
>
> $pdf=new PDF('l','mm','A4');
> $pdf->AliasNbPages();
> $pdf->AddPage();
> $miCodigoDeBarras='80025200100000407';
> $pdf->ImprovedTable($header,$miCodigoDeBarras);
> $pdf->Output(); //Por pantalla. Ver documentacion
> $pdf->Close();
>
>
> Saludos!.
>
> -----Mensaje original-----
> De: ciracusa <ciracusa@gmail.com>
> Enviado: Mier 18-09-2013 12:34
> Para: php-es@lists.php.net;
> Asunto: [PHP-ES] Generar un PDF con un código de barras con los datos de un
> form en PHP
>
> > Hola Lista.
> >
> > Alguien tendrá un ejemplo de la generación de un PDF con un código de
> > barras a partir de un formulario en PHP?
> >
> > Muchas Gracias.
> >
> > Saludos.
> >
> >
> > --
> > PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>