2011-12-01 4 views
0

TCPDF를 사용하여 pdf 보고서 카드를 만들려고합니다.tcpdf를 사용하여 페이지 맨 오른쪽에 PDF_HEADER_LOGO 표시

페이지의 가장 오른쪽에 PDF_HEADER_LOGO을 표시 할 수 있으며 페이지 왼쪽에 PDF_HEADER_TITLEPDF_HEADER_STRING을 표시 할 수 있습니까?

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

답변

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

} 

당신을 감사합니다.

관련 문제