I need to generate a PDF using mPDF and YuGothM.ttc font for a Japanese client. The page I need to export in PDF contains some text which in browser version (HTML) is rendered well, but in the PDF, the same text has some characters using a font and other characters some default font which is not approved by the client. I understand I have to define TTCfontID parameter in every font definition for .ttc files, but I just don't understand the meanings of those definitions and so how to properly configure fonts.
The script is used in a WordPress website using Polylang plugin for translations.
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$pdf = new \Mpdf\Mpdf([
//'mode' => '+aCJK',
'mode' => 'utf-8',
'format' => 'A3-L',
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 5,
'margin_bottom' => 5,
'fontDir' => array_merge($fontDirs, [
ASSETS_DIR ."fonts/Yugothib/",
]),
'fontdata' => $fontData + [
'yugoth' => [
'R' => 'YuGothR.ttc',
'TTCfontID' => [
'R' => 1,
]
],
],
'default_font' => 'yugoth',
'languageToFont' => new CustomLanguageToFontImplementation()
]);
$pdf->autoScriptToLang = true;
$pdf->autoLangToFont = true;
$pdf->showImageErrors = true;
$pdf->allow_charset_conversion = true;
$pdf->SetHTMLHeader();
$pdf->SetHTMLFooter();
$pdf->WriteHTML($this->getHtmlTemplate($stock, $userId, $loadedDate));
$pdf->Output($filepath, 'F');
And the HTML is also taken from a private function within the same class
function getHtmlTemplate($records, $userId, $loadedDate){
$user = $this->getUserInfo($userId);
$companyName = $user->client;
$html = "
<html lang=\"ja\">
<head>
<style>
.table {
font-family: 'yugoth', sans-serif;
font-size: 16px;
font-weight: normal;
}
.column-header {
text-align: center;
vertical-align: middle;
background-color: #777777;
color: #FFFFFF;
}
.cell{
border-left: 1px solid #efefef;
border-bottom: 1px solid #efefef;
}
.cell-last {
border-right: 1px solid #efefef;
}
.a-center {
text-align: center;
}
.w-80 {
width: 80px;
}
.w-quality {
width: 380px;
}
.w-150 {
width: 150px;
}
</style>
</head>
<body lang=\"ja\">
<table border=\"0\" style=\"width: 100%\">
<tr>
<td style=\"width:26%; text-align: left; font-size: 18px\">
<div>" . $companyName ."</div><br />
<div lang='ja'>" . pll__('Stock Info') ."</div>
</td>
<td class=\"a-center\" style=\"width:26%\">
<div style=\"font-size: 50px; color: #004729; font-weight: bold;\" lang='ja'>" . pll__('Stock Report'). "</div>
</td>
<td style=\"width:26%; text-align: right\">
<div>". $date ."</div><br />
<img src=\"" . ASSETS_URL . "images/logo.png\" width=\"200px\" />
</td>
</tr>
</table>
<table class=\"table\" border=\"0\" cellpadding=\"7\">
<thead>
<tr>
<th class=\"column-header\" style=\"width: 100px\">" . pll__("Col 1") ."</th>
<th class=\"column-header\" style=\"width: 100px\">" . pll__("Col 2") ."</th>
<th class=\"column-header w-150\">" . pll__("Col 3") ."</th>
<th class=\"column-header w-quality\">" . pll__("Col 4") . "</th>
<th class=\"column-header\" style=\"width: 100px\">" . pll__("Col 5") . "</th>
<th class=\"column-header w-80\">" . pll__("Col 6") . "</th>
<th class=\"column-header\" style=\"width: 130px\">" . pll__("Col 7") . "</th>
<th class=\"column-header\">" . pll__("Col 8") . "</th>
<th class=\"column-header\">" . pll__("Col 9") . "</th>
<th class=\"column-header\" style=\"width: 100px\">" . pll__("Col 10") . "</th>
<th class=\"column-header\">" . pll__("Col 11") . "</th>
<th class=\"column-header\" style=\"width: 120px\">" . pll__("Coll 12") . "</th>
<th class=\"column-header w-150\">" . pll__("Col 13") . "</th>
<th class=\"column-header w-150\">" . pll__("Col 14") . "</th>
</tr>
</thead>
<tbody>
";
/** #var StockItem $row */
foreach ($records as $row){
$html .= "
<tr>
<td class=\"cell a-center\">" . $row->col1 ."</td>
<td class=\"cell a-center\">".$row->col2."</td>
<td class=\"cell a-center w-150\">". $row->col3 ."</td>
<td class=\"cell w-quality\">".$row->col4."</td>
<td class=\"cell w-150\">".$row->col5."</td>
<td class=\"cell a-center w-80\">".$row->col6."</td>
<td class=\"cell a-center w-80\">".$row->col7."</td>
<td class=\"cell a-center\" lang='ja'>".$row->col8."</td>
<td class=\"cell a-center\">".$row->col9."</td>
<td class=\"cell a-center\">".$row->col10."</td>
<td class=\"cell a-center\">".$row->col11."</td>
<td class=\"cell a-center w-80\">".$row->col12."</td>
<td class=\"cell a-center w-150\">".$row->col13."</td>
<td class=\"cell cell-last a-center w-150\">".$row->col14."</td>
</tr>";
}
$html .= "
</tbody>
</table>
</body>
</html>
";
return $html;
}
}
Can someone help me with a proper configuration for mPDF or suggest some other configuration with other Japanese font which is already working?
Thanks in advance!
Eventually I've changed the script to use TCPDF and this way has actually worked very nice. I know this answer did not respond to the question I've asked, but it solved my problem.
Related
I created a CRUD system and am trying to customize it to make it look better using Bootstrap.
Currently I have the table striped with the "table-striped" class, however, I am trying to change the thead to a different color as I am not a fan of the options given, dark or light.
I also tried using CSS to customize it, but the browser doesn't seem to be loading the CSS even though it says it is linked in the sources.
<table class="table bg-light table-striped table-bordered table-hover rounded">
<thead>
<tr>
<th>ID</th>
<th>PO Number</th>
<th>Site Name</th>
<th>Date Created</th>
<th>Last Updated</th>
<th> </th>
</tr>
</thead>
<tbody>
<?php foreach($data['records'] as $row): ?>
<?php if(isset($data['flash']['id']) && (int) $row['id'] === $data['flash']['id']): ?>
<tr class="table-success">
<?php else: ?>
<tr>
<?php endif; ?>
<td>
<?= $row['id'] ?>
</td>
<td>
<?= $row['poNum'] ?>
</td>
<td>
<?= $row['site_name'] ?>
</td>
<td>
<?= $row['created_at'] ? (new DateTime($row['created_at']))->format('Y-m-d H:i:s') : '' ?>
</td>
<td>
<?= $row['updated_at'] ? (new DateTime($row['created_at']))->format('Y-m-d H:i:s') : '' ?>
</td>
<td>
<img src="img/pencil-square.svg" title="edit" alt="edit" />
<?php if ($_SESSION['userRole'] === 'ADMIN'): ?>
<a onclick="return confirm_delete(<?= $row['id'] ?>);" href="delete.php?id=<?= $row['id'] ?>&page=<?= $data['currentPage'] ?>"><img src="img/trash.svg" class="spacer" title="delete" alt="delete" /></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
You can use this style:
th {
background-color: blue;
color: white;
}
I don't know how you test the CSS, but make sure it works by first using the CSS Internal. Put this code in the <head> tag and test if your CSS code works.
<style type="text/css">
th {
background-color: blue;
color: white;
}
</style>
After you make sure that it works, just transfer the code to an external CSS file.
If the CSS doesn't take effect, try to figure out if it's not overwritten by another CSS somewhere by looking in the browser's developer console.
So you can try this:
.rounded th {
background-color: blue;
color: white;
}
You can also use !important but it's a good practice to not use this !important keyword as it may cause some conflicts somewhere else.
th {
background-color: blue !important;
color: white;
}
I have a table that looks something like this:
ID | photo | ident | status
------------------------------------------------
80 | img/photo1 | ACH3882 | V
81 | img/photo2 | SHD8837 | V
82 | img/photo3 | SFF4837 | X
83 | img/photo4 | DLL3266 | V
Is it possible to change the rows background color, depending on the value? So if status cell value is V, make yellow, and if X make green?
This is my table, and what I have tried:
<table class="blueTable" border="2" style= "background-color: #f9f9f9; color: #000000; margin: 0 auto;" >
<thead style= "background-color: #FFFFFF">
<tr>
<th>Photo</th>
<th>Ident</th>
<th>Status</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
if ($result = $link->query($query)) {
$num_rows = 0;
while ($row = $result->fetch_assoc()) {
$num_rows++;
if($row['status'] == 'V') {
$style = 'style="background-color:#00FF00;';
}
if($row['status'] == 'X') {
$style = 'style="background-color:#FF00FF;';
}
echo
"<tr>
<td>{$row['photo']}</td>
<td>{$row['ident']}</td>
<td>{$row['status']}</td>
<td><a href='delete.php?id={$row['id']};'>Delete</a></td>
</tr>";
}
/*freeresultset*/
$result->free();
}
?>
</tbody>
</table>
But somehow the background color does not change. Any suggestions?
You can use your status var as a class and add the colors for the classes in css like this
.color-v {
background-color: blue;
}
.color-x {
background-color: green;
}
<table class="blueTable" border="2" style= "background-color: #f9f9f9; color: #000000; margin: 0 auto;" >
<thead style= "background-color: #FFFFFF">
<tr>
<th>Photo</th>
<th>Ident</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
if ($result = $link->query($query)) {
$num_rows = 0;
while ($row = $result->fetch_assoc()) {
$num_rows++;
echo
"<tr class='color-{$row['status']}'>
<td>{$row['photo']}</td>
<td>{$row['ident']}</td>
<td>{$row['status']}</td>
</tr>";
}
/*freeresultset*/
$result->free();
}
?>
</tbody>
</table>
I cannot apply the CSS in the table. For example I want the table to be displayed in the middle and to change the font color and size as well. But I can't. Should I use the tbody tag since I have the body one? Also I generate the table data from database.
<?php
include 'connect.php';
$year = $_POST['year'];
$lecturer = $_POST['lecturer'];
$years = array(
2005,
2006,
2007
);
$lecturers = array(
'lec1',
'lec2',
'lec3',
'lec4'
);
if (in_array($lecturer, $lecturers) && in_array($year, $years)) {
$sql = "SELECT unit_name,a1,a2,a3,l1,l2,r1,r2,u1,u2,u3 FROM $lecturer WHERE year=$year";
$result = mysql_query($sql);
}
else {
echo "No data found";
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../statistics/style.css">
</head>
<body>
<div id="mytable">
<table width="900" border="1" cellspacing="1">
<tr>
<tbody>
<td>Unit Name</td>
<td>A1 </td>
<td>A2 </td>
<td>A3 </td>
<td>L1 </td>
<td>L2 </td>
<td>R1 </td>
<td>R2 </td>
<td>U1 </td>
<td>U2 </td>
<td>U3 </td>
</tbody>
</tr>
<?php
while($unit=mysql_fetch_assoc($result)){
echo "<tr>";
echo "<td>".$unit['unit_name']."</td>";
echo "<td>".$unit['a1']."</td>";
echo "<td>".$unit['a2']."</td>";
echo "<td>".$unit['a3']."</td>";
echo "<td>".$unit['l1']."</td>";
echo "<td>".$unit['l2']."</td>";
echo "<td>".$unit['r1']."</td>";
echo "<td>".$unit['r2']."</td>";
echo "<td>".$unit['u1']."</td>";
echo "<td>".$unit['u2']."</td>";
echo "<td>".$unit['u3']."</td>";
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
css:
<!-- principalLecturers
-->
#body{
color:white;
padding-bottom: 20px;
}
#table{
margin:0;
border-collapse: collapse;
color:#b50a1e;
font-family:verdana,arial,sans-serif;
font-size:10px;
}
#table#mytable{
display: table-row-group;
vertical-align: middle;
border-color: inherit
}
I can't see anywhere in your table <table id="table"...>. That's why the styles for #table {...} does not apply.
i have found lots of articles pertaining to auto-resizing rows and columns such as the CSS codes below:
textarea[readonly="readonly"], textarea[readonly] { background-color:white; }
float colWidth = [[[tableView tableColumns] objectAtIndex:1]width];
NSString *content = [[[tempArray objectAtIndex:row] objectForKey:#"tValue"] string];
float textWidth = [content sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:#"Lucida Grande" size:15],NSFontAttributeName ,nil]].width;
float newHeight = ceil(textWidth/colWidth);
newHeight = (newHeight * 17) + 13;
if(newHeight < 47){
return 47;
}
return newHeight;
table {
width: 700px;
}
and
table tr td {
width: 350px;
height: auto;
}
But nothing seems to work with my code
Here is my table code and I want it to auto-resize based on the data that will be fetch from the database:
$myRes = "<form action='' method='post'>
<fieldset style='width: 10px'>
<legend align='left'><strong>Results</strong></legend>
<p>
<table width='auto' border='1' cellspacing='1' cellpadding='1' align='center'>
<tr>
<th align='center' scope='row'>A</th>
<td><textarea class=readonly name=testA id=testA cols=65 rows=3>" . $result['testA'] . "</textarea></td>
</tr>
<tr>
<th scope='row'>B</th>
<td><textarea class=readonly name=testB id=testB cols=65 rows=3>" . $result['testB'] . "</textarea></td>
</tr>
</table>
</p>
</fieldset>
</form>";
try following :
$("textarea").height( $("textarea")[0].scrollHeight );
or
window.setTimeout( function() {
$("textarea").height( $("textarea")[0].scrollHeight );
}, 1);
I have a PowerShell script that runs a disk usage report (From http://gallery.technet.microsoft.com/Disk-Space-HTML-Email-f8b6bbfe)
I'm trying to change it to display folder size as well, but have gotten stuck. I wrote this which works fine:
$volName = "D:\"
$folders = (Get-ChildItem $volName | ?{ $_.PSIsContainer })
foreach ($folders in $folders)
{
$size = (get-childitem $folders.fullname -recurse | measure-object -property length -sum)
write-host $folders.fullname ($size.sum / 1MB)
}
But it doesn't come out right when I try to insert it. This is what I have so far:
# Script will generate Disk Space Report for Exchange Servers (Daily, Weekly, Monthly)
$ErrorActionPreference = "SilentlyContinue";
$scriptpath = $MyInvocation.MyCommand.Definition
$dir = Split-Path $scriptpath
#Variables to configure
$percentWarning = 25;
$percentCritcal = 15;
$smtpServer = "blah#blah.com"
$ReportSender = "blah#blah.com"
$users = "user1#mydomain.com", "user2#mydomain.com";
$MailSubject = "DiskSpace Report for $titledate"
#No change needed from here!!!
$reportPath = "$dir\Logs\"
$reportName = "DiskSpaceRpt_$(get-date -format ddMMyyyy).html";
$diskReport = $reportPath + $reportName
$redColor = "#FF0000"
$orangeColor = "#FBB917"
$whiteColor = "#FFFFFF"
$greenColor = "#7FFF00"
$i = 0;
$computers = $env:COMPUTERNAME;
$datetime = Get-Date -Format "MM-dd-yyyy_HHmmss";
If (Test-Path $diskReport)
{
Remove-Item $diskReport
}
$titleDate = get-date -uformat "%m-%d-%Y - %A"
$header = "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<title>DiskSpace Report</title>
<STYLE TYPE='text/css'>
<!--
table {
border: thin solid #666666;
}
td {
font-family: Tahoma;
font-size: 11px;
border-top: 1px solid #999999;
border-right: 1px solid #999999;
border-bottom: 1px solid #999999;
border-left: 1px solid #999999;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
body {
margin-left: 5px;
margin-top: 5px;
margin-right: 0px;
margin-bottom: 10px;
table {
border: thin solid #000000;
}
-->
</style>
</head>
<body>
<table width='100%'>
<tr bgcolor='#CCCCCC'>
<td colspan='7' height='25' align='center'>
<font face='tahoma' color='#003399' size='4'><strong>DiskSpace Report for $titledate</strong></font>
</td>
</tr>
</table>
"
Add-Content $diskReport $header
$tableHeader = "
<table width='100%'><tbody>
<tr bgcolor=#CCCCCC>
<td width='10%' align='center'>Server</td>
<td width='5%' align='center'>Drive</td>
<td width='25%' align='center'>Folder</td>
<td width='5%' align='center'>Folder Size</td>
<td width='10%' align='center'>Total Capacity(GB)</td>
<td width='5%' align='center'>Used Capacity(GB)</td>
<td width='5%' align='center'>Free Space(GB)</td>
<td width='5%' align='center'>Freespace %</td>
</tr>
"
Add-Content $diskReport $tableHeader
foreach($computer in $computers)
{
$disks = Get-WmiObject -ComputerName $computer -Class Win32_Volume -Filter "DriveType = 3" | Where-Object {$_.Label -ne "System Reserved" -and $_.DriveLetter -ne "C:"}
$computer = $computer.toupper()
foreach($disk in $disks)
{
$deviceID = $disk.Label;
$volName = $disk.Name;
$folders = (Get-ChildItem $volName | ?{ $_.PSIsContainer });
foreach ($folders in $folders)
{
$size = (get-childitem $folders.fullname -recurse | measure-object -property length -sum)
[float]$size = $disk.Capacity;
[float]$freespace = $disk.FreeSpace;
$percentFree = [Math]::Round(($freespace / $size) * 100, 2);
$sizeGB = [Math]::Round($size / 1073741824, 2);
$freeSpaceGB = [Math]::Round($freespace / 1073741824, 2);
$usedSpaceGB = [Math]::Round($sizeGB - $freeSpaceGB, 2);
$color = $greenColor;
if($percentFree -lt $percentWarning)
{
$color = $orangeColor
if($percentFree -lt $percentCritcal)
{
$color = $redColor
}
}
$dataRow = "
<tr>
<td width='10%'>$computer</td>
<td width='5%' align='center'>$volName</td>
<td width='25%' >$folders.fullname</td>
<td width='5%' >$size</td>
<td width='10%' align='center'>$sizeGB</td>
<td width='5%' align='center'>$usedSpaceGB</td>
<td width='5%' align='center'>$freeSpaceGB</td>
<td width='5%' bgcolor=`'$color`' align='center'>$percentFree</td>
</tr>
"
Add-Content $diskReport $dataRow;
Write-Host -ForegroundColor DarkYellow "$computer $deviceID percentage free space = $percentFree";
$i++
}
}
}
$tableDescription = "
</table><br><table width='20%'>
<tr bgcolor='White'>
<td width='10%' align='center' bgcolor='#FBB917'>Warning less than $percentWarning% free space</td>
<td width='10%' align='center' bgcolor='#FF0000'>Critical less than $percentCritcal% free space</td>
</tr>
"
Add-Content $diskReport $tableDescription
Add-Content $diskReport "</body></html>"
if ($i -gt 0)
{
foreach ($user in $users)
{
Write-Host "Sending Email notification to $user"
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$msg = New-Object Net.Mail.MailMessage
$msg.To.Add($user)
$msg.From = $ReportSender
$msg.Subject = $MailSubject
$msg.IsBodyHTML = $true
$msg.Body = get-content $diskReport
$smtp.Send($msg)
$body = ""
}
}
And it comes out looking like this:
http://oi40.tinypic.com/ru9sfb.jpg
Anyone know why the folder name and folder size variables aren't working?
I think the problem (or one of the problems) is this line: foreach ($folders in $folders). It should be foreach ($folder in $folders) and then everywhere in the for loop that you refer to the current folder you should use $folder (not $folders).
Give that a try and see how it looks.
Thanks for the help, turns out modifying the $folder (and created a few other) variables worked. Report with folders and folder sizes:
# Script will generate Disk Space Report for Exchange Servers (Daily, Weekly, Monthly)
$ErrorActionPreference = "SilentlyContinue";
$scriptpath = $MyInvocation.MyCommand.Definition
$dir = Split-Path $scriptpath
#Variables to configure
$percentWarning = 25;
$percentCritcal = 15;
$smtpServer = "blah#blah.com"
$ReportSender = "blah#blah.com"
$users = "user1#mydomain.com", "user2#mydomain.com";
$MailSubject = "DiskSpace Report for $titledate"
#No change needed from here!!!
$reportPath = "$dir\Logs\"
$reportName = "DiskSpaceRpt_$(get-date -format ddMMyyyy).html";
$diskReport = $reportPath + $reportName
$redColor = "#FF0000"
$orangeColor = "#FBB917"
$whiteColor = "#FFFFFF"
$greenColor = "#7FFF00"
$i = 0;
$computers = $env:COMPUTERNAME;
$datetime = Get-Date -Format "MM-dd-yyyy_HHmmss";
If (Test-Path $diskReport)
{
Remove-Item $diskReport
}
$titleDate = get-date -uformat "%m-%d-%Y - %A"
$header = "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<title>DiskSpace Report</title>
<STYLE TYPE='text/css'>
<!--
table {
border: thin solid #666666;
}
td {
font-family: Tahoma;
font-size: 11px;
border-top: 1px solid #999999;
border-right: 1px solid #999999;
border-bottom: 1px solid #999999;
border-left: 1px solid #999999;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
body {
margin-left: 5px;
margin-top: 5px;
margin-right: 0px;
margin-bottom: 10px;
table {
border: thin solid #000000;
}
-->
</style>
</head>
<body>
<table width='100%'>
<tr bgcolor='#CCCCCC'>
<td colspan='7' height='25' align='center'>
<font face='tahoma' color='#003399' size='4'><strong>DiskSpace Report for $titledate</strong></font>
</td>
</tr>
</table>
"
Add-Content $diskReport $header
$tableHeader = "
<table width='100%'><tbody>
<tr bgcolor=#CCCCCC>
<td width='10%' align='center'>Server</td>
<td width='5%' align='center'>Drive</td>
<td width='25%' align='center'>Folder</td>
<td width='5%' align='center'>Folder Size (MB)</td>
<td width='10%' align='center'>Total Capacity(GB)</td>
<td width='5%' align='center'>Used Capacity(GB)</td>
<td width='5%' align='center'>Free Space(GB)</td>
<td width='5%' align='center'>Freespace %</td>
</tr>
"
Add-Content $diskReport $tableHeader
foreach($computer in $computers)
{
$disks = Get-WmiObject -ComputerName $computer -Class Win32_Volume -Filter "DriveType = 3" | Where-Object {$_.Label -ne "System Reserved" -and $_.DriveLetter -ne "C:"}
$computer = $computer.toupper()
foreach($disk in $disks)
{
$deviceID = $disk.Label;
$volName = $disk.Name;
$folders = (Get-ChildItem $volName | ?{ $_.PSIsContainer });
foreach ($folder in $folders)
{
$sizefolder = (get-childitem $folder.fullname -recurse | measure-object -property length -sum)
$FolderPaths = $folder.fullname
[float]$FolderSize = $sizefolder.sum
$foldersizeMB = [Math]::Round($foldersize / 1048576, 2);
[float]$size = $disk.Capacity;
[float]$freespace = $disk.FreeSpace;
$percentFree = [Math]::Round(($freespace / $size) * 100, 2);
$sizeGB = [Math]::Round($size / 1073741824, 2);
$freeSpaceGB = [Math]::Round($freespace / 1073741824, 2);
$usedSpaceGB = [Math]::Round($sizeGB - $freeSpaceGB, 2);
$color = $greenColor;
if($percentFree -lt $percentWarning)
{
$color = $orangeColor
if($percentFree -lt $percentCritcal)
{
$color = $redColor
}
}
$dataRow = "
<tr>
<td width='10%'>$computer</td>
<td width='5%' align='center'>$volName</td>
<td width='25%' >$folderpaths</td>
<td width='5%' >$foldersizeMB</td>
<td width='10%' align='center'>$sizeGB</td>
<td width='5%' align='center'>$usedSpaceGB</td>
<td width='5%' align='center'>$freeSpaceGB</td>
<td width='5%' bgcolor=`'$color`' align='center'>$percentFree</td>
</tr>
"
Add-Content $diskReport $dataRow;
Write-Host -ForegroundColor DarkYellow "$computer $deviceID percentage free space = $percentFree";
$i++
}
}
}
$tableDescription = "
</table><br><table width='20%'>
<tr bgcolor='White'>
<td width='10%' align='center' bgcolor='#FBB917'>Warning less than $percentWarning% free space</td>
<td width='10%' align='center' bgcolor='#FF0000'>Critical less than $percentCritcal% free space</td>
</tr>
"
Add-Content $diskReport $tableDescription
Add-Content $diskReport "</body></html>"
if ($i -gt 0)
{
foreach ($user in $users)
{
Write-Host "Sending Email notification to $user"
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$msg = New-Object Net.Mail.MailMessage
$msg.To.Add($user)
$msg.From = $ReportSender
$msg.Subject = $MailSubject
$msg.IsBodyHTML = $true
$msg.Body = get-content $diskReport
$smtp.Send($msg)
$body = ""
}
}