使用tcpdf将PDF_HEADER_LOGO显示在页面的最右侧

时间:2011-12-01 06:57:58

标签: layout tcpdf

我正在尝试使用TCPDF创建pdf报告卡。

是否可以在页面的最右侧显示PDF_HEADER_LOGO,并在页面左侧显示PDF_HEADER_TITLEPDF_HEADER_STRING

以下是我的代码:

$pdf->SetHeaderData(
  PDF_HEADER_LOGO,
  PDF_HEADER_LOGO_WIDTH,
  'Report Card',
  $val['Student']['name']
);

1 个答案:

答案 0 :(得分:0)

我设法通过扩展http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf中所述的tcpdf类,在页面的最右侧显示徽标,并在左侧显示标题标题和标题字符串。我也提到了PHP TCPDF remove header's bottom border

以下是我的

 <?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); 

} 
谢谢。