-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcreatepdf.php
More file actions
63 lines (61 loc) · 1.88 KB
/
createpdf.php
File metadata and controls
63 lines (61 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
function fetch_data()
{
$output = '';
$conn = mysqli_connect("localhost", "root", "", "project");
$sql = "SELECT * FROM symbols ORDER BY email";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result))
{
$output .= '<tr>
<td>'.$row["name"].'</td>
<td>'.$row["title"].'</td>
<td>'.$row["email"].'</td>
<td>'.$row["year"].'</td>
<td>'.$row["gender"].'</td>
<td>'.$row["fromdate"].'</td>
<td>'.$row["todate"].'</td>
<td>'.$row["people"].'</td>
</tr>
';
}
return $output;
}
if(isset($_POST["generate_pdf"]))
{
require_once('tcpdf/tcpdf.php');
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->SetTitle("EVENT REGISTRATION REPORT");
$obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('helvetica', '', 11);
$obj_pdf->AddPage();
$content = '';
$content .= '
<h4 align="center">EVENT REGISTRATION REPORT</h4><br />
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th width="18%">Name</th>
<th width="25%">Event</th>
<th width="20%">Email</th>
<th width="6%">Year</th>
<th width="10%">Gender</th>
<th width="10%">From date</th>
<th width="10%">To date</th>
<th width="8%">No.of People</th>
</tr>
';
$content .= fetch_data();
$content .= '</table>';
$obj_pdf->writeHTML($content);
$obj_pdf->Output('file.pdf', 'I');
}
?>