I am trying to copy the demo (http://www.fpdf.org/en/tutorial/tuto2.htm) from FPDF.org and have copied the following code:
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);
}
}
A PDF file is generated which is brilliant, however - the Header image does not show? What is going wrong?
Complete code:
<?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');
?>
You are defining a subclass of FPDF
, called PDF
, but you are not using it. Change $pdf = new FPDF()
to $pdf = new PDF()
.