FPDF: Sie Entscheiden, Wann-set Kopf - /Fußzeile Daten

Ich habe gekämpft, mit den header-und footer-Daten seit geraumer Zeit jetzt, und dachte, es war an der Zeit zu Fragen, es hier auf dem forum.

Was ich versuche zu tun ist, entscheiden, dass, wenn eine Seite Hinzugefügt wird, wenn der Kopf - /Fußzeile Hinzugefügt werden soll oder nicht. so code-mäßig will ich den header/footer wird auf on oder off wenn Sie eine Seite hinzufügen.

Ich habe versucht, zu manipulieren die Funktion AddPage indem man ein zusätzliches argument $setFooterHeader die standardmäßig auf true festgelegt ist. Und dann zu versuchen, dieses argument auf false festlegen, wenn ich einen addPage(",",false); ignoriert aber es aus irgendeinem Grund, und ich kann nicht herausfinden, warum.

Wenn ich den default-Wert des Arguments auf false in der Funktion selbst, es funktioniert wie ein Charme, aber, wenn ich versuche, es in meinem Skript und legen Sie es als ein argument, es völlig ignoriert es.

Hier ist ein code-snippet des fpdf.php Datei (Funktion addPage)

function AddPage($orientation='', $size='', $setHeaderFooter=true) 
{ 
     //Start a new page 
     if($this->state==0) 
     $this->Open(); 
     $family = $this->FontFamily; 
     $style = $this->FontStyle.($this->underline ? 'U' : ''); 
     $fontsize = $this->FontSizePt; 
     $lw = $this->LineWidth; 
     $dc = $this->DrawColor; 
     $fc = $this->FillColor; 
     $tc = $this->TextColor; 
     $cf = $this->ColorFlag; 
     if($this->page>0) 
     { 
         //Page footer 
         if ($setHeaderFooter == true) 
         { 
             $this->InFooter = true; 
             $this->Footer(); 
             $this->InFooter = false; 
             //Close page 
             $this->_endpage(); 
         } 
      } 
     //Start new page 
     $this->_beginpage($orientation,$size,$setHeaderFooter); 
     //Set line cap style to square 
     $this->_out('2 J'); 
     //Set line width 
     $this->LineWidth = $lw; 
     $this->_out(sprintf('%.2F w',$lw*$this->k)); 
     //Set font 
     if($family) 
     $this->SetFont($family,$style,$fontsize); 
     //Set colors 
     $this->DrawColor = $dc; 
     if($dc!='0 G') 
     $this->_out($dc); 
     $this->FillColor = $fc; 
     if($fc!='0 g') 
     $this->_out($fc); 
     $this->TextColor = $tc; 
     $this->ColorFlag = $cf; 
     //Page header 
     if ($setHeaderFooter == true) 
     { 
         $this->InHeader = true; 
         $this->Header(); 
         $this->InHeader = false; 
     } 
     //Restore line width 
     if($this->LineWidth!=$lw) 
     { 
         $this->LineWidth = $lw; 
         $this->_out(sprintf('%.2F w',$lw*$this->k)); 
     } 
     //Restore font 
     if($family) 
     $this->SetFont($family,$style,$fontsize); 
     //Restore colors 
     if($this->DrawColor!=$dc) 
     { 
         $this->DrawColor = $dc; 
         $this->_out($dc); 
     } 
     if($this->FillColor!=$fc) 
     { 
         $this->FillColor = $fc; 
         $this->_out($fc); 
     } 
     $this->TextColor = $tc; 
     $this->ColorFlag = $cf; 
} 

Unten ist ein code-snippet von meinem PHP-Skript, die verwendet FPDF

/** PHP FPDF */ 
require_once 'classes/FPDF/fpdf.php'; 
require_once 'classes/FPDI/fpdi.php'; 

class PDF extends FPDI 
{ 
     function Header() 
     { 
         $this->SetFont( 'Arial', 'B', 18 ); //set font to Arial, Bold, and 16 Size 

         //create heading with params 
         //0 - 100% width 
         //9 height 
         //"Page Heading" - With this text 
         //1 - border around it, and center aligned 
         //1 - Move pionter to new line after writing this heading 
         //'C' - center aligned 
         $this->Cell( 0, 9, 'Page Heading', 1, 1, 'C' ); 

         $this->ln( 5 ); 
     } 

     function Footer() 
     { 
         //move pionter at the bottom of the page 
         $this->SetY( -15 ); 

         //set font to Arial, Bold, size 10 
         $this->SetFont( 'Arial', 'B', 10 ); 

         //set font color to blue 
         $this->SetTextColor( 52, 98, 185 ); 

         $this->Cell( 0, 10, 'Footer Text', 0, 0, 'L' ); 

         //set font color to gray 
         $this->SetTextColor( 150, 150, 150 ); 

         //write Page No 
         $this->Cell( 0, 10, 'Page No: ' . $this->PageNo(), 0, 0, 'R' ); 
     } 
 } 

//Create new PDF object 
$pdf = new PDF('P','mm','A4'); 
$pdf->addPage('','',false); 

//Output pdf file 
$pdf->Output('test.pdf','D'); 

Ihre Hilfe ist sehr geschätzt!!

InformationsquelleAutor GuZzie | 2012-02-26
Schreibe einen Kommentar