test_pdf.php 849 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. class TestPDF extends FPDF {
  3. private $currentTextColor = [0, 0, 0];
  4. public function GetFontSize() {
  5. return $this->FontSizePt;
  6. }
  7. public function SetTextColor($r, $g = null, $b = null) {
  8. if($r != 192) {
  9. $this->currentTextColor = [$r, $g, $b];
  10. }
  11. parent::SetTextColor($r, $g, $b);
  12. }
  13. public function Cell($width, $height = 0, $text = "", $border = 0, $line_mode = 0, $align = "", $fill = false, $link = "") {
  14. $font_size = $this->GetFontSize();
  15. if(empty($text)) {
  16. $text = "N/A";
  17. }
  18. if($text == "N/A") {
  19. $this->SetTextColor(192, 192, 192);
  20. $this->SetFontSize($font_size - 2);
  21. }
  22. parent::Cell($width, $height, $text, $border, $line_mode, $align, $fill, $link);
  23. call_user_func_array([$this, "SetTextColor"], $this->currentTextColor);
  24. // Restore font size
  25. $this->SetFontSize($font_size);
  26. }
  27. }
  28. ?>