Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/06/2009, 15:19
Dicinox
 
Fecha de Ingreso: junio-2009
Mensajes: 3
Antigüedad: 15 años, 9 meses
Puntos: 0
Insertar en FPDF datos de formulario

Hola que tal, estoy tratando de hacer una seccion en mi pagina donde las personas puedan solicitar algunos tipos de constancias, mi idea es que las personas puedan entrar en la web rellenar un formulario con algunos datos como nombre y numero de casas y que luego esos datos sean insertados en un pdf que los clientes puedan descargar o imprimir.

El resultado seria algo como: Yo hago constar que el señor AQUI VA EL NOMBRE QUE INSERTARON EN EL FORMULARIO es mi amigo.

Ya he hecho el formato en el pdf, solo falta que inserte los valores del formulario aqui esta el codigo que he utilizado:

La funcion para centar la cabecera:
Código PHP:
<?php

require('fpdf.php');



class 
PDF_HTML extends FPDF

{

    var 
$B=0;

    var 
$I=0;

    var 
$U=0;

    var 
$HREF='';

    var 
$ALIGN='';
function 
PDF($orientation='P',$unit='mm',$format='Letter')
{
    
//Llama al constructor de la clase padre
    
$this->FPDF($orientation,$unit,$format);
    
//Iniciación de variables
    
$this->B=0;
    
$this->I=0;
    
$this->U=0;
    
$this->HREF='';
}


//Cabecera de página
    
function Cabecera($html)

    {

        
//HTML parser

        
$html=str_replace("\n",' ',$html);

        
$a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);

        foreach(
$a as $i=>$e)

        {

            if(
$i%2==0)

            {

                
//Text

                
if($this->HREF)

                    
$this->PutLink($this->HREF,$e);

                elseif(
$this->ALIGN=='center')

                    
$this->Cell(0,5,$e,0,1,'C');

                else

                    
$this->Write(5,$e);

            }

            else

            {

                
//Tag

                
if($e[0]=='/')

                    
$this->CloseTag(strtoupper(substr($e,1)));

                else

                {

                    
//Extract properties

                    
$a2=explode(' ',$e);

                    
$tag=strtoupper(array_shift($a2));

                    
$prop=array();

                    foreach(
$a2 as $v)

                    {

                        if(
preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))

                            
$prop[strtoupper($a3[1])]=$a3[2];

                    }

                    
$this->OpenTag($tag,$prop);

                }

            }

        }

    }



    function 
OpenTag($tag,$prop)

    {

        
//Opening tag

        
if($tag=='B' || $tag=='I' || $tag=='U')

            
$this->SetStyle($tag,true);

        if(
$tag=='A')

            
$this->HREF=$prop['HREF'];

        if(
$tag=='BR')

            
$this->Ln(5);

        if(
$tag=='P')

            
$this->ALIGN=$prop['ALIGN'];

        if(
$tag=='HR')

        {

            if( !empty(
$prop['WIDTH']) )

                
$Width $prop['WIDTH'];

            else

                
$Width $this->$this->lMargin-$this->rMargin;

            
$this->Ln(2);

            
$x $this->GetX();

            
$y $this->GetY();

            
$this->SetLineWidth(0.4);

            
$this->Line($x,$y,$x+$Width,$y);

            
$this->SetLineWidth(0.2);

            
$this->Ln(2);

        }

    }



    function 
CloseTag($tag)

    {

        
//Closing tag

        
if($tag=='B' || $tag=='I' || $tag=='U')

            
$this->SetStyle($tag,false);

        if(
$tag=='A')

            
$this->HREF='';

        if(
$tag=='P')

            
$this->ALIGN='';

    }



    function 
SetStyle($tag,$enable)

    {

        
//Modify style and select corresponding font

        
$this->$tag+=($enable : -1);

        
$style='';

        foreach(array(
'B','I','U') as $s)

            if(
$this->$s>0)

                
$style.=$s;

        
$this->SetFont('',$style);

    }



    function 
PutLink($URL,$txt)

    {

        
//Put a hyperlink

        
$this->SetTextColor(0,0,255);

        
$this->SetStyle('U',true);

        
$this->Write(5,$txt,$URL);

        
$this->SetStyle('U',false);

        
$this->SetTextColor(0);

    }

}

?>
Y aqui la construccion del PDF:
Código PHP:
<?php

require('WriteHTML.php');

$pdf=new PDF_HTML();
$pdf->AddPage();

$pdf->SetFont('times','',20);

$pdf->Image('logo.png',10,12,0,0,'');

$pdf->SetLeftMargin(45);

$pdf->SetFontSize(10);

$pdf->Cabecera('<br><br><p align="center">Direccion Fiscal: Urb. Prados del Golf IV Etapa, Numero 3-19 Cabudare Estado Lara.</p><p align="center">Telefonos: 0251-7192441 - 0424-5171192 - 0414-5101502.</p><p align="center"> Rif V-05248232-8</p><hr>');

$pdf->SetLeftMargin(25);

$pdf->SetRightMargin(20);

$pdf->SetFontSize(12);

$pdf->Cabecera('<br><br><p align="center"> <span><b>A QUIEN PUEDA INTERESAR</b></span></p><br><p style="text-align:justify;">La Asociacion Civil Prados del Golf IV, por medio de la presente, hace constar que el (la) ciudadano (a) _______________________________, Cedula de Identidad No. _______________________, reside en el inmueble Numero ______________ de la Urbanizacion Prados del Golf IV Etapa, desde hace aproximadamente ______.</p><br><br><br><br><p>Constancia que se expide a solicitud de la parte interesada en Cabudare a los  _______ dias del mes de __________ del _____.</p><br><br><br><br><br><br><br><br><br><br><p align="center">_____________________________________________________<Ln><span><b>P/Asociacion Civil Prados del Golf IV</b></span></p>');

$pdf->SetFontSize(8);

$pdf->Cabecera('<br><br><p align="center"> <span><b>FORMATO GENERADO AUTOMATICAMENTE, REQUIERE FIRMA Y SELLO HUMEDO PARA SU VALIDEZ<Ln>SE HAN OMITIDO TILDES Y ACENTOS PARA MAYOR COMPATIBILIDAD</b></span></p>');

$pdf->Output();

?>
Mi pregunta es como sustituyo los _______________________ por los datos que se obtienen desde el formulario