title: How To Insert Header Logo in TCPDF?
body: <p>Here is my code:</p>
  <pre><code>&lt;?php
      include 'includes/session.php';
      
      $range = $_POST['date_range'];
      $ex = explode(' - ', $range);
      $from = date('Y-m-d', strtotime($ex[0]));
      $to = date('Y-m-d', strtotime($ex[1]));
  
      $sql = &quot;SELECT *, SUM(amount) as total_amount FROM deductions&quot;;
      $query = $conn-&gt;query($sql);
      $drow = $query-&gt;fetch_assoc();
      $deduction = $drow['total_amount'];
  
      $from_title = date('M d, Y', strtotime($ex[0]));
      $to_title = date('M d, Y', strtotime($ex[1]));
  
      require_once('../tcpdf/tcpdf.php');  
      $pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);  
      $pdf-&gt;SetCreator(PDF_CREATOR);  
      $pdf-&gt;SetTitle('Payslip: '.$from_title.' - '.$to_title);  
      $pdf-&gt;SetHeaderData('', PDF_HEADER_LOGO, PDF_HEADER_TITLE, PDF_HEADER_STRING);  
      $pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));  
      $pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));  
      $pdf-&gt;SetDefaultMonospacedFont('helvetica');  
      $pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);  
      $pdf-&gt;SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);  
      $pdf-&gt;setPrintHeader(false);  
      $pdf-&gt;setPrintFooter(false);  
      $pdf-&gt;SetAutoPageBreak(TRUE, 10);  
      $pdf-&gt;SetFont('helvetica', '', 11); 
      
      $pdf-&gt;AddPage(); 
      $contents = '';
  
      $sql = &quot;SELECT *, SUM(num_hr) AS total_hr, attendance.employee_id AS empid, employees.employee_id AS employee FROM attendance LEFT JOIN employees ON employees.id=attendance.employee_id LEFT JOIN position ON position.id=employees.position_id WHERE date BETWEEN '$from' AND '$to' GROUP BY attendance.employee_id ORDER BY employees.lastname ASC, employees.firstname ASC&quot;;
  
      $query = $conn-&gt;query($sql);
      while($row = $query-&gt;fetch_assoc()){
          $empid = $row['empid'];
                        
          $casql = &quot;SELECT *, SUM(amount) AS cashamount FROM cashadvance WHERE employee_id='$empid' AND date_advance BETWEEN '$from' AND '$to'&quot;;
        
          $caquery = $conn-&gt;query($casql);
          $carow = $caquery-&gt;fetch_assoc();
          $cashadvance = $carow['cashamount'];
  
          $gross = $row['rate'] * $row['total_hr'];
          $total_deduction = $deduction + $cashadvance;
          $net = $gross - $total_deduction;
  
          $contents .= '
              
              &lt;h2 align=&quot;center&quot;&gt;MixWellWorld&lt;/h2&gt;
          
              &lt;h4 align=&quot;center&quot;&gt;'.$from_title.&quot; - &quot;.$to_title.'&lt;/h4&gt;
              &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;3&quot;&gt;
                  &lt;tr&gt;
                  &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;Company Name&lt;/td&gt;&lt;/tr&gt;
              &lt;/table&gt;
              &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;3&quot;&gt;             
                 
                 &lt;tr&gt;  
                      
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;Employee Name: &lt;/td&gt;
                      &lt;td width=&quot;25%&quot;&gt;&lt;b&gt;'.$row['firstname'].&quot; &quot;.$row['lastname'].'&lt;/b&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;Rate per Hour: &lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;'.number_format($row['rate'], 2).'&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;Employee ID: &lt;/td&gt;
                      &lt;td width=&quot;25%&quot;&gt;'.$row['employee'].'&lt;/td&gt;   
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;Total Hours: &lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;'.number_format($row['total_hr'], 2).'&lt;/td&gt; 
                  &lt;/tr&gt;
                  &lt;tr&gt; 
                      &lt;td&gt;&lt;/td&gt; 
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;&lt;b&gt;Gross Pay: &lt;/b&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;&lt;b&gt;'.number_format(($row['rate']*$row['total_hr']), 2).'&lt;/b&gt;&lt;/td&gt; 
                  &lt;/tr&gt;
                  &lt;tr&gt; 
                      &lt;td&gt;&lt;/td&gt; 
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;Deduction: &lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;'.number_format($deduction, 2).'&lt;/td&gt; 
                  &lt;/tr&gt;
                  &lt;tr&gt; 
                      &lt;td&gt;&lt;/td&gt; 
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;Cash Advance: &lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;'.number_format($cashadvance, 2).'&lt;/td&gt; 
                  &lt;/tr&gt;
                  &lt;tr&gt; 
                      &lt;td&gt;&lt;/td&gt; 
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;&lt;b&gt;Total Deduction:&lt;/b&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;&lt;b&gt;'.number_format($total_deduction, 2).'&lt;/b&gt;&lt;/td&gt; 
                  &lt;/tr&gt;
                  &lt;tr&gt; 
                      &lt;td&gt;&lt;/td&gt; 
                      &lt;td&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;&lt;b&gt;Net Pay:&lt;/b&gt;&lt;/td&gt;
                      &lt;td width=&quot;25%&quot; align=&quot;right&quot;&gt;&lt;b&gt;'.number_format($net, 2).'&lt;/b&gt;&lt;/td&gt; 
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;br&gt;&lt;hr&gt;
          ';
      }
      $pdf-&gt;writeHTML($contents);  
      $pdf-&gt;Output('payslip.pdf', 'I');
  
  ?&gt;
  </code></pre>
  <p>I want to add header logo in the PDF. I am unable to figure out how can I do it.</p>
  <p>2ndly, When I add more tr or td, It doesn't display in PDF. If I add img tag to display logo it is also not working.</p>
  <p>Could you please guide me how should I set a logo in it? Or how can I style the output?</p>
  <p>Here is what I am getting in PDF so far.</p>
  <p><img src="https://i.stack.imgur.com/N989r.png" alt="PDF Output" /></p>