-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdf.php
85 lines (68 loc) · 1.25 KB
/
pdf.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require 'vendor/autoload.php';
require 'functions.php';
$siswa = query("SELECT * FROM siswa");
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$html = '<!DOCTYPE html>
<html lang="en">
<head>
<style>
img {
width: 70px;
}
tr, h1 {
text-align: center;
}
h1 {
text-decoration: underline;
}
table {
position: relative;
left: 10%;
}
</style>
<title>Daftar Siswa</title>
</head>
<body>
<h1>Daftar Siswa</h1>
<table border="1" cellpadding="10" cellspacing="0">
<tr>
<th>No</th>
<th>NISN</th>
<th>Nama</th>
<th>Kelas</th>
<th>Jurusan</th>
</tr>';
$i = 1;
foreach($siswa as $row) {
$html .= '<tr>
<td>'. $i++ .'</td>
<td>
'. $row["nisn"] .'
</td>
<td>
'. $row["nama"] .'
</td>
<td>
'. $row["kelas"] .'
</td>
<td>
'. $row["jurusan"] .'
</td>
</tr>
';
}
$html .= '</table>
</body>
</html>';
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream("Data siswa.pdf");
?>