2016-11-21 1 views
0

에 표시되지 :FPDF 헤더 이미지는 내가 FPDF.org에서 데모 (<a href="http://www.fpdf.org/en/tutorial/tuto2.htm" rel="nofollow noreferrer">http://www.fpdf.org/en/tutorial/tuto2.htm</a>)을 복사하려고 다음 코드를 복사 한 페이지

class PDF extends FPDF { 
    function Header() { 
     $this->Image('http://domain.co.uk/img/quote-header.png', 10, 6, 30); 
     $this->SetFont('Arial', 'B', 15); 
     $this->Cell(80); 
     $this->Cell(30, 10, 'Title', 1, 0, 'C'); 
     $this->Ln(20); 
    } 
} 

PDF 파일 그러나, 화려한이다 생성합니다 - 헤더 이미지가 표시되지 않습니까? 무슨 일 이니?

전체 코드 :

<?php 
    $fullname = $_POST['fullname']; 
    $jobtitle = $_POST['jobtitle']; 
    $organisation = $_POST['organisation']; 
    $department = $_POST['department']; 
    $addressline1 = $_POST['addressline1']; 
    $addressline2 = $_POST['addressline2']; 
    $addressline3 = $_POST['addressline3']; 
    $towncity = $_POST['towncity']; 
    $county = $_POST['county']; 
    $postcode = $_POST['postcode']; 
    $email = $_POST['email']; 
    $telephone = $_POST['telephone']; 

    require('fpdf181/fpdf.php'); 

    class PDF extends FPDF { 
     function Header() { 
      $this->Image('http://domain.co.uk/img/quote-header.png', 10, 6, 30); 
      $this->SetFont('Arial', 'B', 15); 
      $this->Cell(80); 
      $this->Cell(30, 10, 'Title', 1, 0, 'C'); 
      $this->Ln(20); 
     } 
    } 

    $pdf = new FPDF(); 
    $pdf->AliasNbPages(); 
    $pdf->AddPage(); 
    $pdf->SetFont('Arial', '', 10); 

    $pdf->Cell(40, 10, ''. $fullname .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $jobtitle .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $organisation .' ('. $department .')'); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $addressline1 .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $addressline2 .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $addressline3 .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $towncity .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $county .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $postcode .''); 
    $pdf->Ln(8); 
    $pdf->Cell(40, 10, ''. $email .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, ''. $telephone .''); 
    $pdf->Ln(8); 
    $pdf->Cell(40, 10, ''. date("d-m-Y") .''); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, 'Quotation Ref; WQ'. rand() .''); 
    $pdf->Ln(8); 
    $pdf->Cell(40, 10, 'Dear '. $fullname .','); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, 'As requested, please see your quotation below:'); 
    $pdf->Ln(8); 

    for($i = 1; $i <= 5; $i++) 
    $pdf->Cell(0, 10, 'Printing line number ' . $i, 0, 1); 

    $pdf->Cell(40, 10, 'This quotation will be valid for the remainder of 2016 subject to our terms and conditions.'); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, 'Pricing submitted is strictly confidential between Business Ltd. and '. $organisation .'.'); 
    $pdf->Ln(8); 
    $pdf->Cell(40, 10, 'Please do come back to us if you have any queries whatsoever relating to the above quotation or if you would like'); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, 'to discuss further options.'); 
    $pdf->Ln(8); 
    $pdf->Cell(40, 10, 'We look forward to hearing from you in the near future.'); 
    $pdf->Ln(8); 
    $pdf->Cell(40, 10, 'With best wishes,'); 
    $pdf->Ln(4); 
    $pdf->Cell(40, 10, 'Business Ltd.'); 

    $pdf->Output(); 
    $content = $pdf->Output('('. date("m") .'-'. date("Y") .') WQ'. rand() .'.pdf', 'F'); 
?> 
+0

시도해보십시오. $ this-> Image ('http://domain.co.uk/img/quote-header.png',60,30,90,0,'PNG'); – Dave

+0

행운 없음 @Dave. :( –

+0

당신의 pdf에 추가하고 싶은 파일이 있습니까 ('http://domain.co.uk/img/quote-header.png')? – EhsanT

답변

2

당신은 PDF라는 FPDF의 서브 클래스를 정의하는,하지만 당신이 그것을 사용하고 있지 않습니다. $pdf = new FPDF()$pdf = new PDF()으로 변경하십시오.

+0

문제를 잘 발견했습니다 ... – EhsanT

관련 문제