Tema: generar pdf
Ver Mensaje Individual
  #9 (permalink)  
Antiguo 02/12/2004, 12:04
Avatar de The_omars
The_omars
 
Fecha de Ingreso: marzo-2004
Mensajes: 271
Antigüedad: 20 años, 8 meses
Puntos: 0
si eso si tengo entendido pero por que no lo genera?

aquie les mado el codigo en partes ojala y me puedan ayudar

Código PHP:
<?php

if(!class_exists('FPDF'))
{
define('FPDF_VERSION','1.52');

class 
FPDF
{
//Private properties
var $page;               //current page number
var $n;                  //current object number
var $offsets;            //array of object offsets
var $buffer;             //buffer holding in-memory PDF
var $pages;              //array containing pages
var $state;              //current document state
var $compress;           //compression flag
var $DefOrientation;     //default orientation
var $CurOrientation;     //current orientation
var $OrientationChanges//array indicating orientation changes
var $k;                  //scale factor (number of points in user unit)
var $fwPt,$fhPt;         //dimensions of page format in points
var $fw,$fh;             //dimensions of page format in user unit
var $wPt,$hPt;           //current dimensions of page in points
var $w,$h;               //current dimensions of page in user unit
var $lMargin;            //left margin
var $tMargin;            //top margin
var $rMargin;            //right margin
var $bMargin;            //page break margin
var $cMargin;            //cell margin
var $x,$y;               //current position in user unit for cell positioning
var $lasth;              //height of last cell printed
var $LineWidth;          //line width in user unit
var $CoreFonts;          //array of standard font names
var $fonts;              //array of used fonts
var $FontFiles;          //array of font files
var $diffs;              //array of encoding differences
var $images;             //array of used images
var $PageLinks;          //array of links in pages
var $links;              //array of internal links
var $FontFamily;         //current font family
var $FontStyle;          //current font style
var $underline;          //underlining flag
var $CurrentFont;        //current font info
var $FontSizePt;         //current font size in points
var $FontSize;           //current font size in user unit
var $DrawColor;          //commands for drawing color
var $FillColor;          //commands for filling color
var $TextColor;          //commands for text color
var $ColorFlag;          //indicates whether fill and text colors are different
var $ws;                 //word spacing
var $AutoPageBreak;      //automatic page breaking
var $PageBreakTrigger;   //threshold used to trigger page breaks
var $InFooter;           //flag set when processing footer
var $ZoomMode;           //zoom display mode
var $LayoutMode;         //layout display mode
var $title;              //title
var $subject;            //subject
var $author;             //author
var $keywords;           //keywords
var $creator;            //creator
var $AliasNbPages;       //alias for total number of pages

/*******************************************************************************
*                                                                              *
*                               Public methods                                 *
*                                                                              *
*******************************************************************************/
function FPDF($orientation=PDF_ORIENTATION,$unit='mm',$format='A4')
{
    
//Some checks
    
$this->_dochecks();
    
//Initialization of properties
    
$this->page=0;
    
$this->n=2;
    
$this->buffer='';
    
$this->pages=array();
    
$this->OrientationChanges=array();
    
$this->state=0;
    
$this->fonts=array();
    
$this->FontFiles=array();
    
$this->diffs=array();
    
$this->images=array();
    
$this->links=array();
    
$this->InFooter=false;
    
$this->lasth=0;
    
$this->FontFamily='';
    
$this->FontStyle='';
    
$this->FontSizePt=12;
    
$this->underline=false;
    
$this->DrawColor='0 G';
    
$this->FillColor='0 g';
    
$this->TextColor='0 g';
    
$this->ColorFlag=false;
    
$this->ws=0;
    
//Standard fonts
    
$this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique',
        
'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique',
        
'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic',
        
'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats');
    
//Scale factor
    
if($unit=='pt')
        
$this->k=1;
    elseif(
$unit=='mm')
        
$this->k=72/25.4;
    elseif(
$unit=='cm')
        
$this->k=72/2.54;
    elseif(
$unit=='in')
        
$this->k=72;
    else
        
$this->Error('Incorrect unit: '.$unit);
    
//Page format
    
if(is_string($format))
    {
        
$format=strtolower($format);
        if(
$format=='a3')
            
$format=array(841.89,1190.55);
        elseif(
$format=='a4')
            
$format=array(595.28,841.89);
        elseif(
$format=='a5')
            
$format=array(420.94,595.28);
        elseif(
$format=='letter')
            
$format=array(612,792);
        elseif(
$format=='legal')
            
$format=array(612,1008);
        else
            
$this->Error('Unknown page format: '.$format);
        
$this->fwPt=$format[0];
        
$this->fhPt=$format[1];
    }
    else
    {
        
$this->fwPt=$format[0]*$this->k;
        
$this->fhPt=$format[1]*$this->k;
    }

    
//Page orientation
    
$orientation=strtolower($orientation);
    if(
$orientation=='p' or $orientation=='portrait')
    {
        
$this->DefOrientation='P';
        
$this->wPt=$this->fwPt;
        
$this->hPt=$this->fhPt;
    }
    elseif(
$orientation=='l' or $orientation=='landscape')
    {
        
$this->DefOrientation='L';
        
$this->wPt=$this->fhPt;
        
$this->hPt=$this->fwPt;
    }
    else
            
$this->Error('Incorrect orientation: '.$orientation);
        
// NH moved from before Page orientation, fw use wpt instead of fwpt
    
$this->fw=$this->wPt/$this->k;
    
$this->fh=$this->hPt/$this->k;
    
    
$this->CurOrientation=$this->DefOrientation;
    
$this->w=$this->wPt/$this->k;
    
$this->h=$this->hPt/$this->k;
    
//Page margins (1 cm)
    
$margin=28.35/$this->k;
    
$this->SetMargins($margin,$margin);
    
//Interior cell margin (1 mm)
    
$this->cMargin=$margin/10;
    
//Line width (0.2 mm)
    
$this->LineWidth=.567/$this->k;
    
//Automatic page break
    
$this->SetAutoPageBreak(true,2*$margin);
    
//Full width display mode
    
$this->SetDisplayMode('fullwidth');
    
//Compression
    
$this->SetCompression(true);
}

function 
SetMargins($left,$top,$right=-1)
{
    
//Set left, top and right margins
    
$this->lMargin=$left;
    
$this->tMargin=$top;
    if(
$right==-1)
        
$right=$left;
    
$this->rMargin=$right;
}

function 
SetLeftMargin($margin)
{
    
//Set left margin
    
$this->lMargin=$margin;
    if(
$this->page>and $this->x<$margin)
        
$this->x=$margin;
}

function 
SetTopMargin($margin)
{
    
//Set top margin
    
$this->tMargin=$margin;
}

function 
SetRightMargin($margin)
{
    
//Set right margin
    
$this->rMargin=$margin;
}

function 
SetAutoPageBreak($auto,$margin=0)
{
    
//Set auto page break mode and triggering margin
    
$this->AutoPageBreak=$auto;
    
$this->bMargin=$margin;
    
$this->PageBreakTrigger=$this->h-$margin;
}

function 
SetDisplayMode($zoom,$layout='continuous')
{
    
//Set display mode in viewer
    
if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom))
        
$this->ZoomMode=$zoom;
    else
        
$this->Error('Incorrect zoom display mode: '.$zoom);
    if(
$layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default')
        
$this->LayoutMode=$layout;
    else
        
$this->Error('Incorrect layout display mode: '.$layout);
}

function 
SetCompression($compress)
{
    
//Set page compression
    
if(function_exists('gzcompress'))
        
$this->compress=$compress;
    else
        
$this->compress=false;
}

function 
SetTitle($title)
{
    
//Title of document
    
$this->title=$title;
}

function 
SetSubject($subject)
{
    
//Subject of document
    
$this->subject=$subject;
}

function 
SetAuthor($author)
{
    
//Author of document
    
$this->author=$author;
}

function 
SetKeywords($keywords)
{
    
//Keywords of document
    
$this->keywords=$keywords;
}

function 
SetCreator($creator)
{
    
//Creator of document
    
$this->creator=$creator;
}

function 
AliasNbPages($alias='{nb}')
{
    
//Define an alias for total number of pages
    
$this->AliasNbPages=$alias;
}

function 
Error($msg)
{
    
//Fatal error
die('<B>FPDF error: </B>'.$msg);
}

function 
Open()
{
    
//Begin document
    
if($this->state==0)
        
$this->_begindoc();
}

function 
Close()
{
    
//Terminate document
    
if($this->state==3)
        return;
    if(
$this->page==0)
        
$this->AddPage();
    
//Page footer
    
$this->InFooter=true;
    
$this->Footer();
    
$this->InFooter=false;
    
//Close page
    
$this->_endpage();
    
//Close document
    
$this->_enddoc();
}

*** 
continua
?>

Última edición por The_omars; 02/12/2004 a las 12:14