0

I'm trying to create a pdf report card using TCPDF.

Is it possible to display the PDF_HEADER_LOGO to the extreme right of the page and PDF_HEADER_TITLE and PDF_HEADER_STRING to the left of the page?

The following is my code:

$pdf->SetHeaderData(
  PDF_HEADER_LOGO,
  PDF_HEADER_LOGO_WIDTH,
  'Report Card',
  $val['Student']['name']
);
GEOCHET
  • 21,119
  • 15
  • 74
  • 98
vaanipala
  • 1,261
  • 7
  • 36
  • 63

1 Answers1

1

I managed to display the logo to the extreme right of the page and header title and header string to the left by extending the tcpdf class as stated in http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf. I also refered to PHP TCPDF remove header's bottom border

The following is my

 <?php 
App::import('Vendor','tcpdf/tcpdf'); 

class XTCPDF  extends TCPDF 
{ 

var $xheadertext  = 'PDF created using CakePHP and TCPDF'; 
var $xheaderstring = 'headerstring';
var $xheadercolor = array(0,0,200); 
var $xfootertext  = 'Copyright © %d XXXXXXXXXXX. All rights reserved.'; 
var $xfooterfont  = PDF_FONT_NAME_MAIN ; 
var $xfooterfontsize = 8 ; 
//var $xheaderlogo = PDF_HEADER_LOGO;


/** 
* Overwrites the default header 
* set the text in the view using 
*    $fpdf->xheadertext = 'YOUR ORGANIZATION'; 
* set the fill color in the view using 
*    $fpdf->xheadercolor = array(0,0,100); (r, g, b) 
* set the font in the view using 
*    $fpdf->setHeaderFont(array('YourFont','',fontsize)); 
*/ 
function Header() 
{ 

    list($r, $b, $g) = $this->xheadercolor; 
    $this->setY(10); // shouldn't be needed due to page margin, but helas, otherwise it's at the page top
     $this->SetFillColor($r, $b, $g); 
    $this->SetTextColor(0 , 0, 0); 
    $this->Text(15,15,$this->xheadertext); 
    $this->Text(30,15,$this->xheaderstring); 
    $image_file = K_PATH_IMAGES.'logo.jpg'; 
    $this->Image($image_file, 160, 10, 40, '', 'JPG', '', 'T', false, 20, '', false, false, 0, false, false, false); 
   $this->SetFont('helvetica', 'B', 10); 

} 

thank you.

Community
  • 1
  • 1
vaanipala
  • 1,261
  • 7
  • 36
  • 63