Exemplo n.º 1
0
 /**
  * Draw a cell border. This goes from the current X,Y co-ordinates of the document, and 
  * leaves the document cursor at the top right of the bounding box
  * @param doc - a TCPDF document
  * @param width - the width of the cell
  * @param height - the height of the cell
  * @param border - the border data
  */
 private function drawCellBorder($doc, $width, $height, $border)
 {
     //FIRST GET SOME VARIABLES
     $line_widths = PdfTableRow::lineWidthsFromBorderData($border);
     $colour = PdfTableRow::colourFromBorderData($border);
     //NOW GET ALL THE FOUR POINTS
     $top_left = array('x' => $doc->GetX(), 'y' => $doc->GetY());
     $bottom_left = array('x' => $doc->GetX(), 'y' => $doc->GetY() + $height);
     $bottom_right = array('x' => $doc->GetX() + $width, 'y' => $doc->GetY() + $height);
     $top_right = array('x' => $doc->GetX() + $width, 'y' => $doc->GetY());
     //DRAW THE LINES, MAKING SURE TO SET THE WIDTHS FIRST
     //THE LINES GET DRAWN IN THE ORDER top, left, bottom right THE SAME
     //AS THE ORDER OF THE BORDER WIDTHS
     $doc->SetDrawColor($colour['R'], $colour['G'], $colour['B']);
     if ($line_widths['top']) {
         $doc->SetLineWidth($line_widths['top']);
         $doc->Line($top_left['x'], $top_left['y'], $top_right['x'], $top_right['y']);
     }
     if ($line_widths['left']) {
         $doc->SetLineWidth($line_widths['left']);
         $doc->Line($top_left['x'], $top_left['y'], $bottom_left['x'], $bottom_left['y']);
     }
     if ($line_widths['bottom']) {
         $doc->SetLineWidth($line_widths['bottom']);
         $doc->Line($bottom_left['x'], $bottom_left['y'], $bottom_right['x'], $bottom_right['y']);
     }
     if ($line_widths['right']) {
         $doc->SetLineWidth($line_widths['right']);
         $doc->Line($top_right['x'], $top_right['y'], $bottom_right['x'], $bottom_right['y']);
     }
 }
 /**
  * Return the colour from border data
  */
 public static function colourFromBorderData($data)
 {
     $split = explode(';', $data);
     $ret = PdfTableRow::hexToRgb($split[1]);
     return $ret;
 }