Reputation: 1828
I am retrieving data from a database and display on a PDF using FPDF.
The following is what I am trying to achieve:
This is what I did so far :
$pdf->Write(10,"Qualification(1):$text ".$record['Qualification']);
$pdf->Ln(); //Go to a new line
$pdf->Write(10,"Awarding body/Institution:$text1".$record['IssuingBody']);
$pdf->Ln();
$pdf->Write(10,"Date of completion / award:$text2".$record['CompletionDate']);
$pdf->Ln();
$pdf->Write(10,"Purpose of the qualification:$text2".$record['CountryEligibility']);
$pdf->Ln();
$pdf->Write(10,"Minimum duration of study:$text2".$record['EntryRequirements']);
it totally displays incorrectly, hence I am considering displaying it in a borderless table. My first time working with FPDF, Please assist
Upvotes: 2
Views: 3165
Reputation: 1828
A zero in the cell syntax represents no boarder. it works the same for a multicell.
<?php
include_once 'scripts/init.php'; //Connect to the database
require 'fpdf/fpdf.php';
require 'fpdf/rotation.php'; //import fpdf and the watermark class
$aptid = $_SESSION['apt']; //The applicant ID
//Class to create the water mark
class PDF extends PDF_Rotate
{
function Header()
{
//Put the watermark
$this->SetFont('Arial','B',50);
$this->SetTextColor(255,192,203);
$this->RotatedText(35,190,'FOR VERIFICATION ONLY',45);
}
function RotatedText($x, $y, $txt, $angle)
{
//Text rotated around its origin
$this->Rotate($angle,$x,$y);
$this->Text($x,$y,$txt);
$this->Rotate(0);
}
}
$pdf=new PDF(); //create an instance of the fpdf class
$pdf->AddPage(); //create the pdf page
//Retrieve the qualification holder details from the database
$query = "SELECT a.QhFullName, a.QhDOB, a.Qualification, a.IssuingBody, a.CompletionDate, a.EntryRequirements, a.CountryEligibility, a.ProgrammeRequirements, a.MinStudyDuration, a.CountryLevel, a.OrgField, a.SubFramework, a.NQFLevel, a.Credits, a.ClosestQualification
FROM Evaluation a
INNER JOIN Apn b ON a.ApnID = b.AptID
WHERE b.AptID LIKE $aptid";
$stmt = sqlsrv_query( $conn, $query);
$record = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC);
$text = 'Born: ';
$text0 = ' ';
$text1 = ' ';
//heading
$pdf->SetFont("Arial","B",10);
$pdf->Cell(0,10,$record['QhFullName'].$text0.$text.$record['QhDOB'],1,1,"L");
//body of the pdf
$pdf->ln();
//Display the qualification holders details on a pdf table using Cells
$pdf->SetFont("Arial","",06);
$pdf->Cell(80,5,'Qualification(1):',0,0,'L',0);
$pdf->Cell(80,5,$record['Qualification'],0,1,'L',0);
$pdf->Cell(80,5,'Awarding body/Institution:',0,0,'L',0);
$pdf->Cell(80,5,$record['IssuingBody'],0,1,'L',0);
$pdf->Cell(80,5,'Date of completion / award:',0,0,'L',0);
$pdf->Cell(80,5,$record['CompletionDate'],0,1,'L',0);
$pdf->Cell(80,5,'Purpose of the qualification:',0,0,'L',0);
$pdf->Cell(80,5,$record['CountryEligibility'],0,1,'L',0);
$pdf->Cell(80,5,'Minimum entry requirement:',0,0,'L',0);
$pdf->MultiCell( 80, 5,$record['EntryRequirements'], 0);
$pdf->Cell(80,5,'Minimum duration of study:',0,0,'L',0);
$pdf->Cell(80,5,$record['MinStudyDuration'],0,1,'L',0);
$pdf->Cell(80,5,'Requirements for the award:',0,0,'L',0);
$pdf->Cell(80,5,$record['ProgrammeRequirements'],0,1,'L',0);
$pdf->Cell(80,5,'Requirements for the award:',0,0,'L',0);
$pdf->Cell(80,5,$record['CountryLevel'],0,1,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,9,'RECOGNITION DECISION',0,1,'L',0);
$pdf->Cell(80,5,'Qualification(s) describe above:',0,0,'L',0);
$pdf->Cell(80,5,'Closest comparable South African qualification / qualification type',0,1,'L',0);
$pdf->Cell(80,5,'(1):',0,0,'C',0);
$pdf->Cell(80,5,$record['ClosestQualification'],0,1,'L',0);
$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'Organising Field:',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,$record['OrgField'],0,1,'L',0);
$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'Sub-framework location:',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,$record['SubFramework'],0,1,'L',0);
$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'NQF Level(see overleaf):',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,substr($record['NQFLevel'], -1),0,1,'L',0);
$pdf->SetFont("Arial","",08);
$pdf->Cell(80,5,'Credits:',0,0,'L',0);
$pdf->SetFont("Arial","B",08);
$pdf->Cell(80,5,$record['Credits'],0,1,'L',0);
$pdf->Output(); //Output data to the PDF
?>
Upvotes: 3