Roopavathy Posted September 12, 2013 Share Posted September 12, 2013 I want to display Student's Result as a PDF file.I have used fpdf library fromhttp://www.fpdf.org/I have followed their scripts for HTML table (Author Azeem Abbas) Here is my result link: http://bhc.edu.in/commerce/Studresult.php?exno=12345 I want to align the tables' rows and columns.How can i?Please help.My PDF file : (Studresult.php) http://pastebin.com/LdTwc3ya HTML Table by fpdf: (html_table.php) http://pastebin.com/hc6xjPua Thanks in advance Link to comment https://forums.phpfreaks.com/topic/282087-php-to-pdf-report/ Share on other sites More sharing options...
Yohanne Posted September 12, 2013 Share Posted September 12, 2013 Hi. <?php require('fpdf.php'); require('TOURDABASECONNECTION.PHP'); class PDF extends FPDF { function BuildTable($header,$data) { $this->SetFillColor(159,159,158); $this->SetTextColor(0); $this->SetDrawColor(0,0,0); $this->SetLineWidth(.1); $this->SetFont('',''); $w=array(8,35,80,43,30,8,; for($i=0;$i<count($header);$i++) $this->Cell($w[$i],7,$header[$i],1,0,'C',1); $this->Ln(); $this->SetFillColor(201,201,201); $this->SetTextColor(0); $this->SetFont(''); $fill=true; foreach($data as $row) { $this->Cell($w[0],6,$row[0],'LR',0,'C',$fill); $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill); $this->SetTextColor(0); $this->SetFont(''); $this->Cell($w[2],6,$row[2],'LR',0,'L',$fill); $this->Cell($w[3],6,$row[3],'LR',0,'L',$fill); $this->Cell($w[4],6,$row[4],'LR',0,'L',$fill); $this->Cell($w[5],6,$row[5],'LR',0,'C',$fill); $this->Cell($w[6],6,$row[6],'LR',0,'C',$fill); $this->Ln(); $fill =! $fill; } $this->Cell(array_sum($w),0,'','T'); } } $disquery = "Select * from results where Examno = '$exnum'"; $disuser = mysql_query($disquery)or die(mysql_error()); While($row = mysql_fetch_array($disuser)) { $data[] = array( $row['Subcode'], $row['Title'], $row['CIA'], $row['ESE'], $row['Credits'], $row['Grade'], $row['Gradept']); } $pdf = new PDF('P','mm','A3'); $header=array('PAPER CODE','TITLE','CIA','ESE','CREDIT EARNED','GRADE','GRADE POINT'); $pdf->SetFont('Arial','',9); $pdf->AddPage(); $pdf->BuildTable($header,$data); $pdf->Output(); ?> Link to comment https://forums.phpfreaks.com/topic/282087-php-to-pdf-report/#findComment-1449191 Share on other sites More sharing options...
PravinS Posted September 12, 2013 Share Posted September 12, 2013 you can use TCPDF php library using TCPDF library you can directly create PDF of HTML Link to comment https://forums.phpfreaks.com/topic/282087-php-to-pdf-report/#findComment-1449202 Share on other sites More sharing options...
Roopavathy Posted September 16, 2013 Author Share Posted September 16, 2013 Thanks Pravin. Link to comment https://forums.phpfreaks.com/topic/282087-php-to-pdf-report/#findComment-1449646 Share on other sites More sharing options...
Roopavathy Posted September 18, 2013 Author Share Posted September 18, 2013 I have used TCPDF.But when i execute the first example "example_001.php",the pdf opens and displays only the header and footer.But the the HTML content doesn't get displayed.Please help. Link to comment https://forums.phpfreaks.com/topic/282087-php-to-pdf-report/#findComment-1449987 Share on other sites More sharing options...
Recommended Posts