Skip to content

Instantly share code, notes, and snippets.

@cantacoop
Created December 5, 2020 02:01
Show Gist options
  • Save cantacoop/08bd82cd2253d6b5134bcf2eb3adfee7 to your computer and use it in GitHub Desktop.
Save cantacoop/08bd82cd2253d6b5134bcf2eb3adfee7 to your computer and use it in GitHub Desktop.
// pdf html content
$content = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="important stylesheet" href="chrome://messagebody/skin/messageBody.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
@import url("https://fonts.googleapis.com/css2?family=Sarabun&display=swap");
body { font-family: "Sarabun",sans-serif; }
</style>
</head>
<body><style>table, th, td {
border: 0px solid #ddd;
border-collapse: collapse;
white-space: normal;
word-wrap: break-word;
font-family: "Sarabun",sans-serif;
}
td{
padding:5px;
}
</style>';
foreach ($data_sorted as $k => $v){
$content .= '<table>
<tr>
<td colspan="2"><div style="font-size: 24px">New Step Exchange Program Co., Ltd.</div>
<div style="font-size: 18px">อาคารวิเศษศิริ 226 ชั้น 6 ถ.พหลโยธิน,พญาไท,กรุงเทพฯ 10400</div><br /><br />
</td>
</tr>';
//Define column index here
$i=0;
//Consider new row for each entry here
//Get column order wise value here
foreach ($fields as $k2 => $v2){
$colVal = ((isset($v[$k2])) ? html_entity_decode($v[$k2]) : '');
$content .= '<tr><td style="font-weight: bold">'.str_replace('_', ' ', $k2).'</td><td>'.htmlentities(stripslashes($colVal)).'</td></tr>';
}
$content .= '</table>';
}
$content .= '</body></html>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment