MYPDF::columnWidths PHP Method

columnWidths() public method

Create the array which hold the column widths. They depends on the maximum with the time column and the money column need.
public columnWidths ( integer $max_time_width, $max_money_width ) : array
$max_time_width integer maximum width the time column needs.
return array containing the widths of the columns
    public function columnWidths($max_time_width, $max_money_width)
    {
        return array($max_time_width, $this->getPageWidth() - $this->pagedim[$this->page]['lm'] - $this->pagedim[$this->page]['rm'] - $max_time_width - $max_money_width, $max_money_width);
    }

Usage Example

Example #1
0
         $time_width += $pdf->GetStringWidth(strftime($dateformat, $row['time_in']));
     }
     if (isset($columns['from']) && isset($columns['to'])) {
         $time_width += max($pdf->GetStringWidth(strftime($timeformat, $row['time_in'])), $pdf->GetStringWidth(strftime($timeformat, $row['time_out'])));
     } else {
         if (isset($columns['from'])) {
             $time_width += $pdf->GetStringWidth(strftime($timeformat, $row['time_in']));
         } else {
             $time_width += $pdf->GetStringWidth(strftime($timeformat, $row['time_out']));
         }
     }
     $max_time_width = max($max_time_width, $time_width);
 }
 $max_time_width += 10;
 $max_money_width += 10;
 $widths = $pdf->columnWidths($max_time_width, $max_money_width);
 $pdf->printRows($customer[$project_id], $widths);
 if (isset($columns['wage']) && isset($columns['dec_time'])) {
     $pdf->ln();
     $pdf->WriteHtmlCell($widths[0] + $widths[1] + $widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->timespan($pdf->timeSum), '', 0, 0, true, 'R');
     $pdf->ln();
     $pdf->WriteHtmlCell($widths[0] + $widths[1], 6, $pdf->getX(), $pdf->getY(), $kga['lang']['export_extension']['finalamount'] . ':', '', 0, 0, true, 'R');
     $pdf->WriteHtmlCell($widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->money($pdf->moneySum), '', 0, 0, true, 'R');
 } else {
     if (isset($columns['wage'])) {
         $pdf->ln();
         $pdf->WriteHtmlCell($widths[0] + $widths[1], 6, $pdf->getX(), $pdf->getY(), $kga['lang']['export_extension']['finalamount'] . ':', '', 0, 0, true, 'R');
         $pdf->WriteHtmlCell($widths[2], 6, $pdf->getX(), $pdf->getY(), $pdf->money($pdf->moneySum), '', 0, 0, true, 'R');
     } else {
         if (isset($columns['dec_time'])) {
             $pdf->ln();