Foros del Web » Programando para Internet » PHP »

Justificar Texto con fpdf

Estas en el tema de Justificar Texto con fpdf en el foro de PHP en Foros del Web. BUenos dias tengo el siguiente problema estoy utilizando una libreria q se llama Fpdf y siguiendo un script para justificar http://www.fpdf.org/en/script/script8.php este pero no me ...
  #1 (permalink)  
Antiguo 16/05/2015, 06:20
 
Fecha de Ingreso: marzo-2011
Mensajes: 120
Antigüedad: 13 años, 1 mes
Puntos: 3
Justificar Texto con fpdf

BUenos dias tengo el siguiente problema estoy utilizando una libreria q se llama Fpdf y siguiendo un script para justificar
http://www.fpdf.org/en/script/script8.php este

pero no me justifica el texto aqui va mi codigo a ver si pueden ayudarme, intento generar una constancia de trabajo a traves de un sistema automatizado y q lo genere en pdf pero me falta justificar el texto

Código:
<?php
require('com/fpdf.php');


class PDF extends FPDF
{
function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='')
{
    $k=$this->k;
    if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak())
    {
        $x=$this->x;
        $ws=$this->ws;
        if($ws>0)
        {
            $this->ws=0;
            $this->_out('0 Tw');
        }
        $this->AddPage($this->CurOrientation);
        $this->x=$x;
        if($ws>0)
        {
            $this->ws=$ws;
            $this->_out(sprintf('%.3f Tw', $ws*$k));
        }
    }
    if($w==0)
        $w=$this->w-$this->rMargin-$this->x;
    $s='';
    if($fill==1 or $border==1)
    {
        if($fill==1)
            $op=($border==1) ? 'B' : 'f';
        else
            $op='S';
        $s=sprintf('%.2f %.2f %.2f %.2f re %s ', $this->x*$k, ($this->h-$this->y)*$k, $w*$k, -$h*$k, $op);
    }
    if(is_string($border))
    {
        $x=$this->x;
        $y=$this->y;
        if(is_int(strpos($border, 'L')))
            $s.=sprintf('%.2f %.2f m %.2f %.2f l S ', $x*$k, ($this->h-$y)*$k, $x*$k, ($this->h-($y+$h))*$k);
        if(is_int(strpos($border, 'T')))
            $s.=sprintf('%.2f %.2f m %.2f %.2f l S ', $x*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-$y)*$k);
        if(is_int(strpos($border, 'R')))
            $s.=sprintf('%.2f %.2f m %.2f %.2f l S ', ($x+$w)*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k);
        if(is_int(strpos($border, 'B')))
            $s.=sprintf('%.2f %.2f m %.2f %.2f l S ', $x*$k, ($this->h-($y+$h))*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k);
    }
    if($txt!='')
    {
        if($align=='R')
            $dx=$w-$this->cMargin-$this->GetStringWidth($txt);
        elseif($align=='C')
            $dx=($w-$this->GetStringWidth($txt))/2;
        elseif($align=='FJ')
        {
            //Set word spacing
            $wmax=($w-2*$this->cMargin);
            $this->ws=($wmax-$this->GetStringWidth($txt))/substr_count($txt, ' ');
            $this->_out(sprintf('%.3f Tw', $this->ws*$this->k));
            $dx=$this->cMargin;
        }
        else
            $dx=$this->cMargin;
        $txt=str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
        if($this->ColorFlag)
            $s.='q '.$this->TextColor.' ';
        $s.=sprintf('BT %.2f %.2f Td (%s) Tj ET', ($this->x+$dx)*$k, ($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k, $txt);
        if($this->underline)
            $s.=' '.$this->_dounderline($this->x+$dx, $this->y+.5*$h+.3*$this->FontSize, $txt);
        if($this->ColorFlag)
            $s.=' Q';
        if($link)
        {
            if($align=='FJ')
                $wlink=$wmax;
            else
                $wlink=$this->GetStringWidth($txt);
            $this->Link($this->x+$dx, $this->y+.5*$h-.5*$this->FontSize, $wlink, $this->FontSize, $link);
        }
    }
    if($s)
        $this->_out($s);
    if($align=='FJ')
    {
        //Remove word spacing
        $this->_out('0 Tw');
        $this->ws=0;
    }
    $this->lasth=$h;
    if($ln>0)
    {
        $this->y+=$h;
        if($ln==1)
            $this->x=$this->lMargin;
    }
    else
        $this->x+=$w;
}
}


$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->cMargin=10;
$pdf->Ln(60);
$pdf->Cell(57);
$pdf->Cell(70,10,'CONSTANCIA DE TRABAJO');
$pdf->SetFont('Arial','B',10);
$pdf->Ln(20);
$pdf->cMargin=20;
$y=$pdf->GetY();
$pdf->SetXY(15, $y);
$pdf->MultiCell(177, 8, "Quien suscribe, Lcdo. JOSIE ALEJANDRA RODRIGUEZ MENDEZ, mayor de edad,", 1, 1,'FJ');
$pdf->SetXY(0, $y);
$pdf->Ln();
$pdf->MultiCell(180, 8, "Venezolano, Titular de la cedula de identidad N XX.XXX.XXX, en su caracter de GERENTE DE TALENTO HUMANO (E) de la Empresa XXXXXXXXXXXXX, hace constar que el (la) ciudadano (a):  ELOY BLANCO JOSE REINALDO", 0, 1,'FJ');
$pdf->Output();

Etiquetas: fpdf, justificar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:15.