2017-07-14 11 views
2

enter image description hereこれはあっても、私はまだそれが同じ出力を生成して、疑いのあるコードを変更しようとし、PDFを生成しているに、ヘッダコードで..codeigniterのTCPDFでヘッダーとロゴを変更する方法は?

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 
'UTF-8', false); 

// set document information 
    $pdf->SetCreator(PDF_CREATOR); 
    $pdf->SetAuthor('Change me'); 
$pdf->SetTitle('Financial Report'); 
$pdf->SetSubject('Yearly Customer Finanacial Report'); 
$pdf->SetKeywords('Purchase, Sale, Order, Payment'); 

    // set default header data 
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 
    PDF_HEADER_TITLE.' My PDF', PDF_HEADER_STRING, array(0,64,255), 
    array(0,64,100)); 
    $pdf->setFooterData(array(0,64,0), array(0,64,128)); 
+0

しかし、どのように愛しますか?それは私のために非常に新しいsthです... –

+0

正確にどのように私は以下の記事で言った。 – Doug

+0

大丈夫、新鮮な気持ちで試してみよう...もし私が望むものを達成すれば、あなたは報われた星になるでしょう... –

答えて

0

ベース・TCPDFを拡張しなければなりません独自のクラスを作成し、ロゴロジックを上書きします。

代わりにnew YourTcpdf()を呼び出してください。

require_once('tcpdf_include.php'); 


// Extend the TCPDF class to create custom Header and Footer 
class MYPDF extends TCPDF { 

    //Page header 
    public function Header() { 
        // Logo 
        $image_file = K_PATH_IMAGES.'logo_example.jpg'; 
        $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false); 
        // Set font 
        $this->SetFont('helvetica', 'B', 20); 
        // Title 
        $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M'); 
    } 

  
} 

// create new PDF document 
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
// set document information 
$pdf->SetCreator(PDF_CREATOR);  
$pdf->SetAuthor('Change me'); 
$pdf->SetTitle('Financial Report');  
$pdf->SetSubject('Yearly Customer Finanacial Report'); 
$pdf->SetKeywords('Purchase, Sale, Order, Payment'); 
    // set default header data 
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' My PDF', PDF_HEADER_STRING, array(0,64,255), array(0,64,100)); 
$pdf->setFooterData(array(0,64,0), array(0,64,128)); 

完全な例は、ここで見つけることができます: https://tcpdf.org/examples/example_003/

関連する問題