forked from NYCPlanning/edm-metadata-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexppdf_dict.php
More file actions
64 lines (52 loc) · 1.74 KB
/
exppdf_dict.php
File metadata and controls
64 lines (52 loc) · 1.74 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
64
<?php
// reference the Dompdf namespace
use Dompdf\Dompdf;
require 'vendor/autoload.php';
include 'config.php';
$sde_underscore = $_GET['sde_underscore'];
// Connect to the Database
if (isset($_POST["Expor2pdf"])) {
$q = 'SELECT orders, field_name, longform_name, description, geocoded, required, data_type, expected_allowed_values, last_modified_date, no_longer_in_use, notes FROM '.$sde_underscore . ' ORDER BY uid';
$data_dict = pg_query($q);
//fetching the column names of the dd table
$html = '<table class="form-table" style="border:1px solid black;"> <tr style="border:1px solid black;">';
$i = 0;
while ($i < pg_num_fields($data_dict))
{
$fieldName = pg_field_name($data_dict, $i);
$fieldName = ucwords(str_replace("_"," ",$fieldName));
if($fieldName == 'Orders') {
$html .= '<th style="border:1px solid black;"> Order </th>';
} else {
$html .= '<th style="border:1px solid black;">' . $fieldName . '</th>';
}
$i = $i + 1;
}
$html .= '</tr>';
$i = 0;
//fetching and displaying the contents of the db table
while ($row = pg_fetch_row($data_dict))
{
$html .= '<tr style="border:1px solid black;">';
$count = count($row);
for ($y = 0; $y < $count; $y+=1)
{
$c_row = current($row);
$html .= '<td style="border:1px solid black;">' . $c_row . '</td>';
next($row);
}
$i = $i + 1;
}
pg_free_result($data_dict);
$html .= '</table>';
// instantiate and use the dompdf class
$dompdf = new DOMPDF();
$dompdf->load_html($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream($sde_underscore.'.pdf');
}
?>