2014-07-14 24 views
1

我正在從數據庫檢索數據並使用FPDF在PDF上顯示。在PHP中使用fpdf的無邊界表格

以下就是我想實現:enter image description here

這是我做過什麼,到目前爲止:

$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

您是否嘗試使用css/html設計PDF格式的內容? – HddnTHA

+1

查看FPDF的[表格教程](http://www.fpdf.org/en/tutorial/tuto5.htm)。基本上你想要[cells](http://www.fpdf.org/en/doc/cell.htm)沒有邊框(第四個參數)。 – VMai

回答

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 
?>