我正在从数据库中检索数据并使用FPDF在PDF上显示。
以下是我想要实现的目标:
这是我到目前为止所做的:
$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']);
它完全显示不正确,因此我正在考虑在无边框表格中显示它。我第一次使用FPDF,请协助
答案 0 :(得分:1)
单元格语法中的零表示没有寄宿生。对于多单元,它的工作原理相同。
<?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
?>