0
votes

I am new to using dompdf, I am unable to use a css file or just inline css to alter the formatting of the pdf I am having created. I would like to change the size of my font, the color, and cell colors for my table. I am not sure how to make this work using Dompdf. Thank you for the help! I have some examples of how I was attempting to do it in my code.

HTML/PHP Code:

$week_ending_date = date("m-d-Y", strtotime('this friday'));
$table = "table";
$tableBackground = "background: red";
$four = "2";
$pdf = "<html>
<head><title>Weekly Report</title></head>
<body>
<basefont size=".$four.">
<center><h4>Citations</h4>";
$pdf .= "<h4>".$pdfTimeFrame."</h4>";
$pdf .= "<h4>All Items from ".$Start." to ".$End."</h4></center>";
$pdf .= "<div id=".$table.">
         <table style=".$tableBackground.">
            <thead>
                <tr>
                    <th>Week Ending</th>
                    <th>W Number</th>
                    <th>Project Title</th>
                    <th>Project Contact</th>
                    <th>N Number</th>
                    <th>Verified By</th>
                    <th>Date Verified</th>
                    <th>Comments</th>
                    <th>Notes</th>
                    <th>Received</th>
                </tr>
            </thead>
            <tbody>";
while($row = oci_fetch_array($runQuery, OCI_ASSOC+OCI_RETURN_NULLS))
{
    $WNumber = $row['P_NUMBER']."-".$row['A_NUMBER'];

    $querySQLDB = "SELECT [Verified_By], [Comments], [Notes], [Date_Verified], [Week_Ending], [Date_Received] 
           FROM dbo.Information 
           WHERE dbo.Information.Key_ID = '$WNumber' 
           ORDER BY dbo.Information.ID DESC";
    $dbe->query($querySQLDB);
    $sqlData = $dbe->fetch();
    $WeekEndingLessTime = str_replace("12:00:00:000AM"," ",$sqlData['Week_Ending']);
    $dateNoTime = str_replace("12:00:00:000AM"," ",$sqlData['Date_Verified']);
    $dateReceived = str_replace(":00:000"," ",$sqlData['Date_Received']);
    $pdf .= "<tr>
                <td>
                ".$week_ending_date."
                </td>
                <td>
                ".$WNumber."
                </td>
                <td>
                ".$row['TITLE']."
                </td>
                <td>
                ".$row['PROJECT_MANAGER_N']."
                </td>
                <td>
                ".$row['PROJECT_MANAGER_O']."
                </td>
                <td>
                ".$sqlData['Verified_By']."
                </td>
                <td>
                ".$dateNoTime."
                </td>
                <td>
                ".$sqlData['Comments']."
                </td>
                <td>
                ".$sqlData['Notes']."
                </td>
                <td>
                ".$dateReceived."
                </td>
             </tr>
            ";
}
$pdf .= "   </tbody>
         </table>
         </div>";
$pdf .= "</body></html>";

$dompdf = new DOMPDF(); 
$dompdf->load_html($pdf);
$dompdf->render();
$dompdf->stream("Report_'".$week_ending_date."'.pdf", $pdf);
1

1 Answers

0
votes
$pdf = "<html>
<head>
  <style>
  body{
      color: blue;
  }
  </style>
  <title>Weekly Report</title>
</head>

Basically I was trying to format in the wrong place. It's working now though.