0% found this document useful (0 votes)
161 views37 pages

In Partial Fulfillment For The Award of The Degree Of: Internal Examiner External Examiner

This document describes a mini project report on a student result report generation system. The system automatically calculates student semester grade point average (SGPA) and cumulative grade point average (CGPA), reducing manual effort. It analyzes student results by subject and generates graphs. The system has modules for students, staff, and administrators. The implementation details include front-end and back-end technologies like PHP and databases. Screenshots illustrate the system's pages and functions. Future work may include additional report formats.

Uploaded by

anon_724485865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views37 pages

In Partial Fulfillment For The Award of The Degree Of: Internal Examiner External Examiner

This document describes a mini project report on a student result report generation system. The system automatically calculates student semester grade point average (SGPA) and cumulative grade point average (CGPA), reducing manual effort. It analyzes student results by subject and generates graphs. The system has modules for students, staff, and administrators. The implementation details include front-end and back-end technologies like PHP and databases. Screenshots illustrate the system's pages and functions. Future work may include additional report formats.

Uploaded by

anon_724485865
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 37

REPORT

Dr. Mahalingam GENERATION


College USING
of Engineering and Technology
STUDENT’S
Pollachi -RESULT
642003
An Autonomous Institution

Affiliated to Anna University, Chennai - 600 025

Project Website: https://sites.google.com/site/reportgenerationcse/


BONAFIDE CERTIFICATE

Certified that this mini project report, “REPORT GENERATION USING


MINI PROJECT REPORT
STUDENT’S RESULT”
is the bonafide work of
Submitted by

ABINAYA
ABINAYA D. D. (12BCS001)
(12BCS001)
ABINAYA
ABINAYA K. K. (12BCS002)
(12BCS002)
ABINAYA
ABINAYA T. T. (12BCS003)
(12BCS003)
KARTHIKA
KARTHIKA E. E. (13BCS307)
(13BCS307)

who carried out the project


in partial work under
fulfillment myaward
for the supervision.
of the degree

of

Bachelor of Engineering
Prof. Gowrishankar A. Kanagasabapathy T.
HEAD OF THE DEPARTMENT in SUPERVISOR
Computer Science and Engineering Assistant Professor
Computer Science
Dr. Mahalingam College of Engineering Computerand Engineering
Science and Engineering
and Technology, NPT-MCET Campus Dr. Mahalingam College of Engineering
Dr. Mahalingam
Pollachi – 642003 India College of Engineering
and Technology, and Technology
NPT-MCET Campus
PollachiPollachi – 642003 India
- 642003
Submitted for the Autonomous End Semester Examination Mini Project
An Autonomous Institution
Viva-voce held on _______________________
Affiliated to Anna University, Chennai - 600 025

MAY 2015

INTERNAL EXAMINER EXTERNAL EXAMINER


REPORT GENERATION USING STUDENT’S RESULT
ABSTRACT

The report generation is mainly used for displaying student results with CGPA
and SGPA. The present system in our college has no automatic calculation for SGPA
and CGPA.

In this proposed system, we calculate the SGPA and CGPA automatically. Thus
reducing manual efforts involved in calculating the SGPA and CGPA. We also analyze
the result of each subject of the semester separately and generate a graph for it.
ACKNOWLEDGEMENT

First and foremost, we wish to express our deep unfathomable feeling, gratitude
to our institution and our department for providing us a chance to fulfill our long
cherished of becoming engineers. We express our sincere thanks to our honorable
Secretary Prof.C.Ramaswamy M.E.,F.I.V., for providing us with required amenities.

We sincerely thank our director Dr.S.Vijayarangan M.E.,Ph.D.,F.I.E., for his


moral support and encouragement for our project. We wish to express our hearty thanks
to Dr.M.Ramakrishnan M.E.,Ph.D., Principal of our college, for his constant
motivation and continual encouragement regarding our project work.

We thank Dr.A.Rathinavelu M.Tech.,Ph.D.,MISTE.,MCSI.,MACM., Vice


Principal of our college for his constant encouragement regarding our project work. We
are grateful to Prof . A.Gowri shankar,M.E(Ph.D) Head of the Department, Computer
Science and Engineering, for his direction delivered at all times required. We also thank
him for his tireless and meticulous efforts in bringing out this project to its logical
conclusion.

Our hearty thanks to our guide, Mr.T.Kanagasabapathy, Assistant Professor,


Department of Computer Science Engineering for her constant support and guidance
offered to us during the course of our project by being one among us and all the noble
hearts that gave us immense encouragement towards the completion of our project. We
consider ourself very fortunate for being able to work with a very considerate and
encouraging Assistant Professor like her. Without her offering to accomplish this
application, we would not be able to finish our project on material repository.

We sincerely thank our project coordinator Dr. Reghu Anguswamy, Assistant


Professor and my review members Prof . A.Gowri shankar, Assistant Professor (SG)
and Mrs.N.Sumathi, Assistant Professor, Department of Computer Science and
Engineering, for their valuable support and encouragement in developing this project
successfully.

Finally, we thank all those who have contributed directly and indirectly towards
the success of this project.
LIST OF ABBREVIATIONS

CGPA : Cumulative Grade Point Average

DB : Database

PDF : Portable Document Format

PHP : Personal Home Page

SGPA : Students Grade Point Average

SQL : Structured Query Language

iii
TABLE OF CONTENTS

1. INTRODUCTION....................................................................................................................1
1.1 Objective..........................................................................................................................1
1.2 Project Overview.............................................................................................................1
2. SYSTEM STUDY.....................................................................................................................2
2.1 Existing System.................................................................................................................2
2.2 Pitfalls in Existing System..................................................................................................2
2.3 Proposed System..............................................................................................................2
3. SYSTEM DESIGN....................................................................................................................4
3.1 Student Module................................................................................................................4
3.2 Staff Module....................................................................................................................4
3.3 Admin Module..................................................................................................................4
4. SYSTEM IMPLEMENTATION..................................................................................................6
5. IMPLEMENTATION DETAILS..................................................................................................7
5.1 Front End..........................................................................................................................7
5.2 Back End...........................................................................................................................7
6. PAGE LAYOUT........................................................................................................................8
7. SUMMARY AND FUTURE WORK........................................................................................13
REFERENCES...............................................................................................................................14
APPENDIX A: SOURCE CODE............................................................................................A.1
A.1 LOGIN FORM.................................................................................................................A.1
A.2 DATABASE CONNECTIVITY.............................................................................................A.1
A.3 MODIFICATION OF RESSULT..........................................................................................A.2
A.4 GRAPH GENERATION.....................................................................................................A.3
A.5 RETRIEVING DATA..........................................................................................................A.3
A.6 PDF GENERATION..........................................................................................................A.6

iv
LIST OF FIGURES

Figure 1.Schema Diagram............................................................................................................6


Figure 2.Home Page.....................................................................................................................8
Figure 3.Login Form....................................................................................................................9
Figure 4.Credit Allocation Form..................................................................................................9
Figure 5.Graph Generation...........................................................................................................9
Figure 6.Report Generation.........................................................................................................9
Figure 7.SGPA and CGPA display form.....................................................................................10
Figure 8.Subject Allocation Form..............................................................................................11
Figure 9.Subject Result Analysis................................................................................................11
Figure 10.Admin options............................................................................................................12
Figure 11.Excel uploading Form................................................................................................12

v
LIST OF TABLES
Table I. Grade Point Allocation....................................................................................................5

vi
1. INTRODUCTION

The main aim of the project is to analyse the result of each semester and to
calculate the SGPA and CGPA for each student. Results are analysed and graph are
generated for the whole semester result and for each subject separately.

1.1 Objective

To establish an ease of work for generating a report. This product is specially


prepared for generating the report. The main objective is to reduce the work of the
faculty in analysing the result.

This system gives an approximate result to the end user. The report generated
can be easily viewed and produced in the user friendly manner

1.2 Project Overview

The activities performed will be helpful to measure the performance of the


students in particular subjects to know about his/her SGPA and CGPA.

The inputs are given by the administrator and he/she has all the access rights.
This project is done using wampserver and dreamweaver.

1
2. SYSTEM STUDY

The problem has been identified and then a system has been selected to solve the
problem based on the existing system. In this phase, the following activities are carried
out by comparing the existing system and then the proposed system is formed.

2.1 Existing System

At present the report is done manually. The faculty has to generate it manually
and check the report several times according to their satisfaction.

Its more time consuming. There is a chance of reflecting mistakes in the report
since it is done manually.

2.2 Pitfalls in Existing System

 It has been decided that the problem in the existing system can be
solvable by computerization. The exact time limit to solve the problem
has been clearly identified and the initial investigation was done by
studying.

 The organization responsible for the current system and identifying the
information flow (students details in the database) the duty of the existing
organization provides background knowledge of the problem
environment.

2.3 Proposed System

The proposed system can be used to overcome the manual inconvenience.This


system can be done for satisfying the faculty in analyzing the result. The proposed
system is to improve report maintenance.

The advantages of this proposed system are:

 Reduce Time to search the records.

 System automation of day to day work of “report generation”

2
 Usage of system would help in proper storage of records.

 Save time consumption

 Computerized work

 Error free report generation

 Quicker and faster access of stored data to fetch according to the need of
faculty.

3
3. SYSTEM DESIGN

This project automates all the details of the report generation. This project
consist of three modules.

 Student module

 Staff module

 Admin module

3.1 Student Module

In the student module each student has an unique login id and password[1]. If a
student has logged in he/she can view or download the result. To view or download the
result he/she should re-enter their roll number[2]. The result is downloaded in the PDF
form[3]. In the PDF the roll number, name, subjects, laboratories, CGPA and SGPA are
displayed.

3.2 Staff Module

In the staff module each staff member has their own login id and password. Each
staff can view the students mark individually and also for the whole class. Staff can
view the overall result and he/she can analyze the result for the subjects they are
handling[4]. Staffs can generate graphs for each semester[5]. Count of S,A,B,C,D,E,RA
grades are analyzed in the graph and the percentage is displayed in the graph.

3.3 Admin Module

In the admin module the admin uploads the semester results in the database[6].
He/she has the privilege to enter the credits for each semester. He also allocates the
subjects for each staff. He/she has a separate privilege to modify the marksheet of each
student[7].

4
Table I. Grade Point Allocation

GRADE MARKS POINTS


S 91-100 10
A 81-90 9
B 71-80 8
C 61-70 7
D 56-60 6
E 51-55 5
RA <50 0

5
4. SYSTEM IMPLEMENTATION

Initially four classes namely students, subjects&laboratory, admin and staff were
designed. Each class have specific functionalities and with the help of these
functionalities we implemented our system.

SUBJECTS &
LABORATORY
sub1
STUDENTS sub2 ADMIN
name sub3 id
rollno studies +n sub4 +1 allocates name
+1 +n
subjects sub5
laboratories sub6 excel uploading()
lab1 allocating credits()
view result() lab2 modifyiing result()
download result() lab3 allocating staffs for subjects()
opname()
+n
+n
+n

handels
analyze
controls

+n +1
+n

STAFF
name
id

view result()
grade analysis()
generate graph()

Figure 1.Schema Diagram

6
5. IMPLEMENTATION DETAILS

5.1 Front End

The front end of this application is PHP. PHP is a server side scripting language.
It is the most popular scripting language in the web application. Each page in our
application has been designed using HTML tags. The form is validated using
JavaScript.

5.2 Back End

The back end of this application is MYSQL.It is the world’s most popular and
widely used open source database technology and data storage system. It offers
reliability and ease of use.

7
8
6. PAGE LAYOUT

Figure 2.Home Page

Figure 2 is the home page of this project. It has three login namely Admin login,
Staff login, Student login.

Figure 3.Login Form

Figure 3 is the student login form. To login each individual has a separate login
id and password

9
Figure 4.Credit Allocation Form

Figure 4 is the form to allocate the credits for each course in the semester.Based
on the credits the SGPA will be calculated.

Figure 5.Graph Generation

Figure 5 is the graph generated for the semester results. This is a PDF file
in which graph is generated by fetching values from DB.Grades of each subjects and
laboratories are taken and then the graph is generated

10
Figure 6.Report Generation

Figure 6 is the marksheet generated for an individual student. It is generated


in the PDF format. This PDF can be downloaded.

Figure 7.SGPA and CGPA display form

Figure 7 is the form where the SGPA and CGPA for the whole class is displayed.

11
Figure 8.Subject Allocation Form

Figure 8 is the form where the admin allocates the staff for the corresponding
subject.

Figure 9.Subject Result Analysis

Figure 9 is the form which is used to analysis the result of each subject.

12
Figure 10.Admin options

Figure 10 is the form which displays the different options of the admin such as
subjects and credits allocation,excel uploading and modifying marksheet.

Figure 11.Excel uploading Form

Figure 11 is the form for uploading the result of the semester.The excel sheet
containing mark list of the students are uploaded into the database.

13
7. SUMMARY AND FUTURE WORK

It is a web based application. The student can view and download their mark
report. The application can be used in any educational institutions. The staff can analyze
the subject results by generating graph. Our application generates the report using the
database. It is a benefit for the admin as it reduces their manual work.

This project can be extended for all the departments in the college. Also the
internal marks can be updated and analyzed.

14
REFERENCES

15
APPENDIX A: SOURCE CODE

A.1 LOGIN FORM

1. <h3>STAFF LOGIN</h3>
2. <!-- Begin Page Content -->
3. <div id="container">
4. <form name="login" action="logindb.php" method="post">
5. <label for="username">User Name:</label>
6. <input type="text" id="username" name="username" >
7. <label for="password">Password</label>
8. <input type="password" id="password" name="password">
9. <div id="lower">
10. <input type="submit" value="Login">
11. </div><!--/ lower-->
12. </form>
13. </div><!--/ container-->
14. <!-- End Page Content -->
15. </body>
16. </html>

A.2 DATABASE CONNECTIVITY

1. <?php
2. session_start();
3. $username = $_POST['username'];
4. $password = $_POST['password'];
5. if($username && $password)
6. {
7. $connect = mysqli_connect("localhost","root","") or
die("Couldn't connect!");
8. mysqli_select_db($connect,'abi') or die("Couldn't find db");
9.
10. $query= mysqli_query($connect,"SELECT * From staff WHERE
username='$username'");
11. $numrows = mysqli_num_rows($query);
12. if ($numrows!=0)
13. {
14. //code to login
15. while ($row = mysqli_fetch_assoc($query))
16. {
17. $dbusername = $row['username'];
18. $dbpassword = $row['password'];
19. }
20. if($username==$dbusername&&$password==$dbpassword)
21. {
22. echo '<script>window.location="staff1.php";</script>';
23. }
24. else
25. echo "Incorrect password!";

16
26. }
27. else
28. die("That user does't exist!");
29. }
30. else
31. die("Please enter username and Password!");
32.
33. ?>

A.3 MODIFICATION OF RESULT

1. <?php
2. error_reporting(0);
3. mysql_connect("localhost","root","");
4. mysql_select_db("phlo");
5. if(isset($_POST['submit']) && $_POST['submit']!='')
6. {
7. {
8. $ROLLNO =$_POST['ROLLNO'];
9. $SUB1 =$_POST['SUB1'];
10. $SUB2 =$_POST['SUB2'];
11. $SUB3 =$_POST['SUB3'];
12. $SUB4 =$_POST['SUB4'];
13. $SUB5 =$_POST['SUB5'];
14. $SUB6 =$_POST['SUB6'];
15. $LAB1 =$_POST['LAB1'];
16. $LAB2 =$_POST['LAB2'];
17. $LAB3 =$_POST['LAB3'];
18. if(trim($ROLLNO)=='' && trim($SUB1)=='' &&
trim($SUB2)=='' && trim($SUB3)=='' && trim($SUB4)=='' &&
trim($SUB5)=='' && trim($SUB6)=='' && trim($LAB1)=='' &&
trim($LAB2)=='' && trim($LAB3)=='' )
19. {
20. echo '<script>alert("Please fill all required
fields");</script>';
21. echo
'<script>window.location="modifymarksheet1.php";</script>';
22. }
23. }
24. else
25. {
26. mysql_query("UPDATE upload1 SET ROLLNO = '".$ROLLNO."',
SUB1 = '".$SUB1."',SUB2 = '".$SUB2."',SUB3 = '".$SUB3."', SUB4 =
'".$SUB4."',SUB5 ='".$SUB5."' , SUB6 ='".$SUB6."',LAB1 ='".
$LAB1."', LAB2 ='".$LAB2."', LAB3 ='".$LAB3."' WHERE ROLLNO='".
$_POST['ROLLNO']."'") or die(mysql_error());
27. echo '<script>alert("Successfully Updated");</script>';
28. echo
'<script>window.location="viewinduvid1.php";</script>';
29. }
30. }?>

17
A.4 GRAPH GENERATION

1. <?php
2. require('diag.php');
3. $pdf = new PDF_Diag();
4. $pdf->AddPage();
5. $data = array('SGRADE' => 8, 'AGRADE' => 7, 'BGRADE' =>
6 ,'CGRADE' => 3,'DGRADE' => 1,'EGRADE' => 14);
6. //Pie chart
7. $pdf->SetFont('Arial', 'BIU', 12);
8. $pdf->Cell(0, 5, 'GRADE ANALYSIS FOR 5TH SEMESTER', 0, 1);
9. $pdf->Ln(8);
10. $pdf->SetFont('Arial', '', 10);
11. $valX = $pdf->GetX();
12. $valY = $pdf->GetY();
13. $pdf->Cell(30, 5, 'NUMBER OF S GRADE:');
14. $pdf->Cell(15, 5, $data['SGRADE'], 0, 0, 'R');
15. $pdf->Ln();
16. $pdf->Cell(30, 5, 'NUMBER OF A GRADE:');
17. $pdf->Cell(15, 5, $data['AGRADE'], 0, 0, 'R');
18. $pdf->Ln();
19. $pdf->Cell(30, 5, 'NUMBER OF B GRADE:');
20. $pdf->Cell(15, 5, $data['BGRADE'], 0, 0, 'R');
21. $pdf->Ln();
22. $pdf->Cell(30, 5, 'NUMBER OF C GRADE:');
23. $pdf->Cell(15, 5, $data['CGRADE'], 0, 0, 'R');
24. $pdf->Ln();
25. $pdf->Cell(30, 5, 'NUMBER OF D GRADE:');
26. $pdf->Cell(15, 5, $data['DGRADE'], 0, 0, 'R');
27. $pdf->Ln();
28. $pdf->Cell(30, 5, 'NUMBER OF E GRADE:');
29. $pdf->Cell(15, 5, $data['EGRADE'], 0, 0, 'R');
30. $pdf->Ln();
31. $pdf->Ln(20);
32. $pdf->SetXY(90, $valY);
33. $col1=array(100,255,255);
34. $col2=array(255,100,100);
35. $col3=array(255,100,255);
36. $col4=array(100,255,100);
37. $col5=array(255,255,100);
38. $col6=array(100,100,255);
39. $pdf->PieChart(100, 35, $data, '%l (%p)',
array($col1,$col2,$col3,$col4,$col5,$col6));
40. $pdf->SetXY($valX, $valY + 40);
41. $pdf->Output();
42. ?>

A.5 RETRIEVING DATA

1. <?php
2. mysql_connect("localhost","root","");

18
3. mysql_select_db("phlo");
4. {

5. {
6. if(isset($_POST['submit']) && $_POST['submit']!="")
7. {
8. if(isset($_POST['rollno']) && trim($_POST['rollno'])!="")
9. {
10. $getuser=mysql_query("SELECT * FROM upload1 WHERE
ROLLNO='".$_POST['rollno']."'");
11. $data=mysql_fetch_assoc($getuser);
12. }
13. else
14. {
15. echo '<script>alert("Please fill out All Required
field");</script>';
16. echo '<script>window.location="index.php";</script>';
17. }
18. }
19. ?>
20. <html>
21. <head>
22. <link href="css/bootstrap.min.css" rel="stylesheet"
media="screen">
23. <link href="css/bootstrap-responsive.min.css"
rel="stylesheet" media="screen">
24. <script type="text/javascript" src="js/jquery-
1.8.0.min.js"></script>
25. <script type="text/javascript"
src="js/bootstrap.min.js"></script>
26. <title>How to create Contact Form using Bootstrap |
PGPGang.com</title>
27. </head>
28. <body>
29. <div class="container">
30. <form class="contact-us form-horizontal"
action="actionpdf.php" method="post">
31. <legend>Fill Form and submit to generate PDF</legend>
32. <div class="control-group">
33. <label class="control-label">rollno</label>
34. <div class="controls">
35. <div class="input-prepend">
36. <span class="add-on"><i class="icon-user"></i></span>
37. <input type="text" class="input-xlarge" name="rollno"
placeholder="enter your rollno" value="<?php echo
$data['rollno'];?>" >
38. </div>
39. </div>
40. </div>
41. <div class="control-group">
42. <label class="control-label">sub1</label>
43. <div class="controls">
44. <div class="input-prepend">
45. <span class="add-on"><i class="icon-globe"></i></span>
46. <input type="text" class="input-xlarge" name="sub1"
placeholder="enter uour grade">
47. </div>
48. </div>
49. </div>

19
50. <div class="control-group">
51. <label class="control-label">sub2</label>
52. <div class="controls">
53. <div class="input-prepend">
54. <span class="add-on"><i class="icon-globe"></i></span>
55. <input type="text" class="input-xlarge" name="sub2"
placeholder="enter uour grade">
56. </div>
57. </div>
58. </div>
59. <div class="control-group">
60. <label class="control-label">sub3</label>
61. <div class="controls">
62. <div class="input-prepend">
63. <span class="add-on"><i class="icon-globe"></i></span>
64. <input type="text" class="input-xlarge" name="sub3"
placeholder="enter uour grade">
65. </div>
66. </div>
67. </div>
68. <div class="control-group">
69. <label class="control-label">sub4</label>
70. <div class="controls">
71. <div class="input-prepend">
72. <span class="add-on"><i class="icon-globe"></i></span>
73. <input type="text" class="input-xlarge" name="sub4"
placeholder="enter uour grade">
74. </div>
75. </div>
76. </div>
77. <div class="control-group">
78. <label class="control-label">sub5</label>
79. <div class="controls">
80. <div class="input-prepend">
81. <span class="add-on"><i class="icon-globe"></i></span>
82. <input type="text" class="input-xlarge" name="sub5"
placeholder="enter uour grade">
83. </div>
84. </div>
85. </div>
86. <div class="control-group">
87. <label class="control-label">sub6</label>
88. <div class="controls">
89. <div class="input-prepend">
90. <span class="add-on"><i class="icon-globe"></i></span>
91. <input type="text" class="input-xlarge" name="sub6"
placeholder="enter uour grade">
92. </div>
93. </div>
94. </div>
95. <div class="control-group">
96. <label class="control-label">sub6</label>
97. <div class="controls">
98. <div class="input-prepend">
99. <span class="add-on"><i class="icon-globe"></i></span>
100. <input type="text" class="input-xlarge" name="sub6"
placeholder="enter uour grade">
101. </div>
102. </div>

20
103. </div>
104. <div class="control-group">
105. <label class="control-label">lab1</label>
106. <div class="controls">
107. <div class="input-prepend">
108. <span class="add-on"><i class="icon-globe"></i></span>
109. <input type="text" class="input-xlarge" name="lab1"
placeholder="enter uour grade">
110. </div>
111. </div>
112. </div>
113. <div class="control-group">
114. <label class="control-label">lab2</label>
115. <div class="controls">
116. <div class="input-prepend">
117. <span class="add-on"><i class="icon-globe"></i></span>
118. <input type="text" class="input-xlarge" name="lab2"
placeholder="enter uour grade">
119. </div>
120. </div>
121. </div>
122. <div class="control-group">
123. <label class="control-label">lab3</label>
124. <div class="controls">
125. <div class="input-prepend">
126. <span class="add-on"><i class="icon-globe"></i></span>
127. <input type="text" class="input-xlarge" name="lab3"
placeholder="enter uour grade">
128. </div>
129. </div>
130. </div>
131. <div class="control-group">
132. <label class="control-label">Comment</label>
133. <div class="controls">
134. <div class="input-prepend">
135. <span class="add-on"><i class="icon-pencil"></i></span>
136. <textarea name="comment" class="span4" rows="4" cols="80"
placeholder="Comment (Max 200 characters)"></textarea>
137. </div>
138. </div>
139. </div>
140.
141.
142. <div class="control-group">
143. <div class="controls">
144. <button type="submit" class="btn btn-
primary">Submit</button>
145. <button type="button" class="btn">Cancel</button>
146. </div>
147. </div>
148. </form>
149. </div>
150. </body>
151. </html>

21
A.6 PDF GENERATION

1. <?php
2. require('fpdf.php');
3. require('htmlparser.inc.php');
4. class PDF_HTML extends FPDF
5. {
6. var $B=0;
7. var $I=0;
8. var $U=0;
9. var $HREF='';
10. var $ALIGN='';
11. function WriteHTML($html)
12. {
13. //HTML parser
14. $html=str_replace("\n",' ',$html);
15. $a=preg_split('/<(.*)>/U',$html,-
1,PREG_SPLIT_DELIM_CAPTURE);
16. foreach($a as $i=>$e)
17. {
18. if($i%2==0)
19. {
20. //Text
21. if($this->HREF)
22. $this->PutLink($this->HREF,$e);
23. elseif($this->ALIGN=='center')
24. $this->Cell(0,3,$e,0,1,'C');
25. else
26. $this->Write(5,$e);
27. }
28. else
29. {
30. //Tag
31. if($e[0]=='/')
32. $this->CloseTag(strtoupper(substr($e,1)));
33. else
34. {
35. //Extract properties
36. $a2=explode(' ',$e);
37. $tag=strtoupper(array_shift($a2));
38. $prop=array();
39. foreach($a2 as $v)
40. {
41. if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
42. $prop[strtoupper($a3[1])]=$a3[2];
43. }
44. $this->OpenTag($tag,$prop);
45. }
46. }
47. }
48. }
49.
50. function OpenTag($tag,$prop)
51. {
52. //Opening tag
53. if($tag=='B' || $tag=='I' || $tag=='U')
54. $this->SetStyle($tag,true);

22
55. if($tag=='A')
56. $this->HREF=$prop['HREF'];
57. if($tag=='BR')
58. $this->Ln(5);
59. if($tag=='P')
60. $this->ALIGN=$prop['ALIGN'];
61. if($tag=='HR')
62. {
63. if( !empty($prop['WIDTH']) )
64. $Width = $prop['WIDTH'];
65. else
66. $Width = $this->w - $this->lMargin-$this->rMargin;
67. $this->Ln(2);
68. $x = $this->GetX();
69. $y = $this->GetY();
70. $this->SetLineWidth(0.4);
71. $this->Line($x,$y,$x+$Width,$y);
72. $this->SetLineWidth(0.2);
73. $this->Ln(2);
74. }
75. if($tag=='BLOCKQUOTE'){
76. $this->SetLeftMargin(28);
77. $this->Ln(10);
78. }
79. if($tag=='PARA'){
80. $this->SetLeftMargin(50);
81. $this->Ln(10);
82. }
83. if($tag=='TAB'){
84. $this->SetLeftMargin(65);
85. }
86. /*if($tag=='NAME'){
87. $n = "Azam Wahaj";
88. //$this->Write(5, $n);
89. $this->Cell(0 , 5, $n, 0, 0, 'L', false, '');
90. }
91. if($tag=='ADDRESS'){
92. $address = "skjhdkajshfkjhsdkf salkdfjls";
93. //$this->Write(5, $n);
94. $this->Cell(0 , 5, $address, 0, 0, 'L', false, '');
95. }*/
96. if($tag=='TAB2'){
97. $this->SetLeftMargin(110);
98. }
99. }
100. function CloseTag($tag)
101. {
102. //Closing tag
103. if($tag=='B' || $tag=='I' || $tag=='U')
104. $this->SetStyle($tag,false);
105. if($tag=='A')
106. $this->HREF='';
107. if($tag=='P')
108. $this->ALIGN='';
109. if($tag=='BLOCKQUOTE')
110. $this->SetLeftMargin(20);
111. //$this->Ln(5);
112. if($tag=='PARA')
113. $this->SetLeftMargin(20);

23
114. if($tag=='TAB')
115. $this->SetLeftMargin(28);
116. if($tag=='TAB2')
117. $this->SetLeftMargin(28);
118. }
119. }
120. }
121. function SetStyle($tag,$enable)
122. {
123. //Modify style and select corresponding font
124. $this->$tag+=($enable ? 1 : -1);
125. $style='';
126. foreach(array('B','I','U') as $s)
127. if($this->$s>0)
128. $style.=$s;
129. $this->SetFont('',$style);
130. }
131. }
132. function PutLink($URL,$txt)
133. {
134. //Put a hyperlink
135. $this->SetTextColor(0,0,255);
136. $this->SetStyle('U',true);
137. $this->Write(5,$txt,$URL);
138. $this->SetStyle('U',false);
139. $this->SetTextColor(0);
140. }
141. }
142. //Page footer
143. function Footer()
144. {
145. //Position at 1.5 cm from bottom
146. $this->SetY(-15);
147. //Arial italic 8
148. $this->SetFont('Arial','I',8);
149. //Page number
150. $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
151. }
152. }function WriteTable($data, $w)
153. {
154. //$this->SetLineWidth(.1);
155. $this->SetFillColor(255,255,255);
156. $this->SetTextColor(0);
157. //$this->SetFont('Arial','',8);
158. foreach($data as $row)
159. {
160. $nb=0;
161. for($i=0;$i<count($row);$i++)
162. $nb=max($nb,$this->NbLines($w[$i],trim($row[$i])));
163. $h=5*$nb;
164. $this->CheckPageBreak($h);
165. for($i=0;$i<count($row);$i++)
166. {
167. $x=$this->GetX();
168. $y=$this->GetY();
169. $this->Rect($x,$y,$w[$i],$h);
170. $this->MultiCell($w[$i],5,trim($row[$i]),0,'L');
171. //Put the position to the right of the cell
172. $this->SetXY($x+$w[$i],$y);//

24
173. }
174. $this->Ln($h);
175. }
176. }
177. function NbLines($w, $txt)
178. {
179. //Computes the number of lines a MultiCell of width w will
take
180. $cw=&$this->CurrentFont['cw'];
181. if($w==0)
182. $w=$this->w-$this->rMargin-$this->x;
183. $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
184. $s=str_replace("\r",'',$txt);
185. $nb=strlen($s);
186. if($nb>0 && $s[$nb-1]=="\n")
187. $nb--;
188. $sep=-1;
189. $i=0;
190. $j=0;
191. $l=0;
192. $nl=1;
193. while($i<$nb)
194. {
195. $c=$s[$i];
196. if($c=="\n")
197. {
198. $i++;
199. $sep=-1;
200. $j=$i;
201. $l=0;
202. $nl++;
203. continue;
204. }
205. if($c==' ')
206. $sep=$i;
207. $l+=$cw[$c];
208. if($l>$wmax)
209. {
210. if($sep==-1)
211. {
212. if($i==$j)
213. $i++;
214. }
215. else
216. $i=$sep+1;
217. $sep=-1;
218. $j=$i;
219. $l=0;
220. $nl++;
221. }
222. else
223. $i++;
224. }
225. return $nl;
226. }
227. function CheckPageBreak($h)
228. {
229. //If the height h would cause an overflow, add a new page
immediately

25
230. if($this->GetY()+$h>$this->PageBreakTrigger)
231. $this->AddPage($this->CurOrientation);
232. }
233. function ReplaceHTML($html)
234. {
235. $html = str_replace( '<li>', "\n<br> - " , $html );
236. $html = str_replace( '<LI>', "\n - " , $html );
237. $html = str_replace( '</ul>', "\n\n" , $html );
238. $html = str_replace( '<strong>', "<b>" , $html );
239. $html = str_replace( '</strong>', "</b>" , $html );
240. $html = str_replace( '&#160;', "\n" , $html );
241. $html = str_replace( '&nbsp;', " " , $html );
242. $html = str_replace( '&quot;', "\"" , $html );
243. $html = str_replace( '&#39;', "'" , $html );
244. $html = str_replace( '<br>', "\n<br>" , $html );
245. $html = str_replace( '<h1>', "</h1>" , $html );
246. $html = str_replace( '<center>', "</center>" , $html );
247. return $html;
248. }
249. function ParseTable($Table)
250. {
251. $_var='';
252. $htmlText = $Table;
253. $parser = new HtmlParser ($htmlText);
254. while ($parser->parse())
255. {
256. if(strtolower($parser->iNodeName)=='table')
257. {
258. if($parser->iNodeType == NODE_TYPE_ENDELEMENT)
259. $_var .='/::';
260. else
261. $_var .='::';
262. }
263. if(strtolower($parser->iNodeName)=='tr')
264. {
265. if($parser->iNodeType == NODE_TYPE_ENDELEMENT)
266. $_var .='!-:'; //opening row
267. else
268. $_var .=':-!'; //closing row
269. }
270. if(strtolower($parser->iNodeName)=='td' && $parser-
>iNodeType == NODE_TYPE_ENDELEMENT)
271. {
272. $_var .='#,#';
273. }
274. if ($parser->iNodeName=='Text' && isset($parser-
>iNodeValue))
275. {
276. $_var .= $parser->iNodeValue;
277. }
278. }
279. $elems =
explode(':-!',str_replace('/','',str_replace('::','',str_replace
('!-:','',$_var)))); //opening row
280. foreach($elems as $key=>$value)
281. {
282. if(trim($value)!='')
283. {
284. $elems2 = explode('#,#',$value);

26
285. array_pop($elems2);
286. $data[] = $elems2;
287. }
288. }
289. return $data;
290. }
291. function WriteHTML2($html)
292. {
293. $html = $this->ReplaceHTML($html);
294. //Search for a table
295. $start = strpos(strtolower($html),'<table');
296. $end = strpos(strtolower($html),'</table');
297. if($start!==false && $end!==false)
298. {
299. $this->WriteHTML2(substr($html,0,$start).'<BR>');
300. {
301. $tableVar = substr($html,$start,$end-$start);
302. $tableData = $this->ParseTable($tableVar);
303. for($i=1;$i<=count($tableData[0]);$i++)
304. {
305. if($this->CurOrientation=='L')
306. $w[] = abs(80/(count($tableData[0])-1))+24; //80 => 120
307. else
308. $w[] = abs(80/(count($tableData[0])-1))+5; //80 => 120
309. }
310. $this->WriteTable($tableData,$w);
311. }
312. $this->WriteHTML3(substr($html,$end+8,strlen($html)-
1).'<BR>');
313. }
314. else
315. {
316. $this->WriteHTML3($html);
317. }
318. }
319. function PDF($orientation='P', $unit='mm', $format='A4')
320. {
321. //Call parent constructor
322. $this->FPDF($orientation,$unit,$format);
323. //Initialization
324. $this->B=0;
325. $this->I=0;
326. $this->U=0;
327. $this->HREF='';
328. }
329. function WriteHTML3($html)
330. {
331. //HTML parser
332. $html=str_replace("\n",' ',$html);
333. $a=preg_split('/<(.*)>/U',$html,-
1,PREG_SPLIT_DELIM_CAPTURE);
334. foreach($a as $i=>$e)
335. {
336. if($i%2==0)
337. {
338. //Text
339. if($this->HREF)
340. $this->PutLink($this->HREF,$e);
341. else

27
342. $this->Write(5,$e);
343. }
344. else
345. {
346. //Tag
347. if($e[0]=='/')
348. $this->CloseTag(strtoupper(substr($e,1)));
349. else
350. {
351. //Extract attributes
352. $a2=explode(' ',$e);
353. $tag=strtoupper(array_shift($a2));
354. $attr=array();
355. foreach($a2 as $v)
356. {
357. if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
358. $attr[strtoupper($a3[1])]=$a3[2];
359. }
360. $this->OpenTag($tag,$attr);
361. }
362. }
363. }
364. }
365. /*class PDF_HTML_Table extends FPDF
366. {
367. var $B;
368. var $I;
369. var $U;
370. var $HREF;
371. function PDF($orientation='P', $unit='mm', $format='A4')
372. {
373. //Call parent constructor
374. $this->FPDF($orientation,$unit,$format);
375. //Initialization
376. $this->B=0;
377. $this->I=0;
378. $this->U=0;
379. $this->HREF='';
380. }
381. function WriteHTML2($html)
382. {
383. //HTML parser
384. $html=str_replace("\n",' ',$html);
385. $a=preg_split('/<(.*)>/U',$html,-
1,PREG_SPLIT_DELIM_CAPTURE);
386. foreach($a as $i=>$e)
387. {
388. if($i%2==0)
389. {
390. //Text
391. if($this->HREF)
392. $this->PutLink($this->HREF,$e);
393. else
394. $this->Write(5,$e);
395. }
396. else
397. {
398. //Tag
399. if($e[0]=='/')

28
400. $this->CloseTag(strtoupper(substr($e,1)));
401. else
402. {
403. //Extract attributes
404. $a2=explode(' ',$e);
405. $tag=strtoupper(array_shift($a2));
406. $attr=array();
407. foreach($a2 as $v)
408. {
409. if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
410. $attr[strtoupper($a3[1])]=$a3[2];
411. }
412. $this->OpenTag($tag,$attr);
413. }
414. }
415. }
416. }
417. function OpenTag($tag, $attr)
418. {
419. //Opening tag
420. if($tag=='B' || $tag=='I' || $tag=='U')
421. $this->SetStyle($tag,true);
422. if($tag=='A')
423. $this->HREF=$attr['HREF'];
424. if($tag=='BR')
425. $this->Ln(5);
426. if($tag=='P')
427. $this->Ln(10);
428. }
429. function CloseTag($tag)
430. {
431. //Closing tag
432. if($tag=='B' || $tag=='I' || $tag=='U')
433. $this->SetStyle($tag,false);
434. if($tag=='A')
435. $this->HREF='';
436. if($tag=='P')
437. $this->Ln(10);
438. }
439. function SetStyle($tag, $enable)
440. {
441. //Modify style and select corresponding font
442. $this->$tag+=($enable ? 1 : -1);
443. $style='';
444. foreach(array('B','I','U') as $s)
445. if($this->$s>0)
446. $style.=$s;
447. $this->SetFont('',$style);
448. }
449. function PutLink($URL, $txt)
450. {
451. //Put a hyperlink
452. $this->SetTextColor(0,0,255);
453. $this->SetStyle('U',true);
482.$this->Write(5,$txt,$URL);<HTML>

29
30

You might also like