/** * Render the tag content. * * @return void */ public function close() { $this->pdf->setFont($this->font, $this->fontStyle, $this->fontSize); $fontColor = Xml2Pdf::convertColor($this->fontColor); $this->pdf->setTextColor($fontColor['r'], $fontColor['g'], $fontColor['b']); $this->pdf->MultiCell(190, $this->lineHeight, $this->content, false, $this->textAlign, false); }
/** * Constructor. * * Parse the tag attributes and add the new line to the document. * * @param array $tagProperties tag properties * @return void */ public function __construct($tagProperties) { $pdf = Pdf::singleton(); $lineColor = $tagProperties['LINECOLOR']; if ($lineColor != '') { $drawColor = Xml2Pdf::convertColor($lineColor); $pdf->SetDrawColor($drawColor['r'], $drawColor['g'], $drawColor['b']); } $lineWidth = $tagProperties['LINEWIDTH']; if ($lineWidth != '') { $currentLW = $pdf->LineWidth; $pdf->SetLineWidth((double) $lineWidth); } $x1 = $this->mathEval($tagProperties['LEFT']); $x2 = $this->mathEval($tagProperties['RIGHT']); $y1 = $this->mathEval($tagProperties['TOP']); $y2 = $this->mathEval($tagProperties['TOP']); $pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2); $y1 = $this->mathEval($tagProperties['BOTTOM']); $y2 = $y1; $pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2); //$x1 = $this->mathEval($tagProperties['LEFT']); $x2 = $x1; $y1 = $this->mathEval($tagProperties['TOP']); $y2 = $this->mathEval($tagProperties['BOTTOM']); $pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2); $x1 = $this->mathEval($tagProperties['RIGHT']); $x2 = $x1; //$y1 = $this->mathEval($tagProperties['TOP']); //$y2 = $this->mathEval($tagProperties['BOTTOM']); $pdf->Line((double) $x1, (double) $y1, (double) $x2, (double) $y2); if ($lineWidth != '') { $pdf->SetLineWidth($currentLW); } }
public function __construct($tagProperties) { $pdf = Pdf::singleton(); $x = $tagProperties['LEFT']; $y = $tagProperties['TOP']; $w = $tagProperties['WIDTH']; $h = $tagProperties['HEIGHT']; $r = $tagProperties['RADIUS']; $style = $tagProperties['STYLE']; $angle = $tagProperties['ANGLE']; $lineColor = $tagProperties['LINECOLOR']; if ($lineColor != '') { $drawColor = Xml2Pdf::convertColor($lineColor); $pdf->SetDrawColor($drawColor['r'], $drawColor['g'], $drawColor['b']); } $lineWidth = $tagProperties['LINEWIDTH']; if ($lineWidth != '') { $current = $pdf->LineWidth; $pdf->SetLineWidth((double) $lineWidth); } $pdf->RoundedRect($x, $y, $w, $h, $r, $angle, $style); if ($lineWidth != '') { $pdf->SetLineWidth($current); } }
/** * Show table title. * * @return void */ public function render() { // set colors $borderColor = Xml2Pdf::convertColor($this->borderColor); $this->pdf->SetDrawColor($borderColor["r"], $borderColor["g"], $borderColor["b"]); $fillColor = Xml2Pdf::convertColor($this->fillColor); $this->pdf->SetFillColor($fillColor["r"], $fillColor["g"], $fillColor["b"]); $fontColor = Xml2Pdf::convertColor($this->fontColor); $this->pdf->setTextColor($fontColor["r"], $fontColor["g"], $fontColor["b"]); $this->pdf->SetFont($this->font, $this->fontStyle, $this->fontSize); // Save the current position $x = $this->pdf->GetX(); $y = $this->pdf->GetY(); $this->pdf->MultiCell($this->table->width, $this->lineHeight, $this->content, $this->border, $this->textAlign, $this->fill); }
/** * Constructor. * * Parse the tag attributes * * @param array $tagAttributes tag attributes * @return void */ public function __construct($tagAttributes) { parent::__construct($tagAttributes); $left = $top = 0; if (isset($tagAttributes['REF'])) { $ref = $tagAttributes['REF']; } if (isset($tagAttributes['URL'])) { $url = $tagAttributes['URL']; } if (isset($tagAttributes['NAME'])) { $name = $tagAttributes['NAME']; } if (isset($tagAttributes['LEFT'])) { $left = $tagAttributes['LEFT']; } if (isset($tagAttributes['TOP'])) { $top = $tagAttributes['TOP']; } // par default les liens sont en bleu et souligné if (!isset($tagAttributes['FONTCOLOR'])) { $this->fontColor = '#0000FF'; } if (!isset($tagAttributes['FONTSTYLE'])) { $this->fontStyle = 'U'; } // positionne le curseur if ($left > 0) { $this->pdf->SetX($left); } if ($top > 0) { $this->pdf->SetY($top); } $this->pdf->setFont($this->font, $this->fontStyle, $this->fontSize); $color = Xml2Pdf::convertColor($this->fontColor); $this->pdf->setTextColor($color['r'], $color['g'], $color['b']); if (isset($ref) && isset($name)) { if (!isset($this->pdf->linksIds[$ref])) { $this->pdf->linksIds[$ref] = $this->pdf->AddLink(); } $url = $this->pdf->linksIds[$ref]; } $this->pdf->Write($this->pdf->defaultLn, $name, $url); }
/** * Render the footer. * * @return boolean */ public function render() { if ($this->endPage && $this->endPage < $this->pdf->PageNo() || $this->startPage > $this->pdf->PageNo()) { return false; } foreach ($this->elements as $paragraph) { $content = null; $this->_resetFontValues(); if (is_a($paragraph, 'xml2pdf_tag_numerotation')) { $content = sprintf($paragraph->content, $this->pdf->PageNo()); } // initialize parametters $contentLength = $this->pdf->GetStringWidth($paragraph->content); $width = isset($paragraph->width) ? $paragraph->width : $contentLength + 20; $textalign = isset($paragraph->textAlign) ? $paragraph->textAlign : $this->textAlign; $align = isset($paragraph->align) ? $paragraph->align : $this->align; $lineHeight = isset($paragraph->lineHeight) ? $paragraph->lineHeight : $this->lineHeight; $border = isset($paragraph->border) ? $paragraph->border : $this->border; $borderColor = Xml2Pdf::convertColor(isset($paragraph->borderColor) ? $paragraph->borderColor : $this->borderColor); $fill = isset($paragraph->fill) ? $paragraph->fill : $this->fill; $fillColor = Xml2Pdf::convertColor(isset($paragraph->fillColor) ? $paragraph->fillColor : $this->fillColor); $font = isset($paragraph->font) ? $paragraph->font : $this->font; $fontSize = isset($paragraph->fontSize) ? $paragraph->fontSize : $this->fontSize; $fontStyle = isset($paragraph->fontStyle) ? $paragraph->fontStyle : $this->fontStyle; $fontColor = Xml2Pdf::convertColor(isset($paragraph->fontColor) ? $paragraph->fontColor : $this->fontColor); $textalign = isset($paragraph->textAlign) ? $paragraph->textAlign : $this->textAlign; $position = isset($paragraph->position) ? $paragraph->position : 'relative'; $left = isset($paragraph->left) ? $paragraph->left : $this->left; $top = isset($paragraph->top) ? $paragraph->top : $this->top; //set colors $this->pdf->SetDrawColor($borderColor["r"], $borderColor["g"], $borderColor["b"]); $this->pdf->SetFillColor($fillColor["r"], $fillColor["g"], $fillColor["b"]); $this->pdf->setTextColor($fontColor["r"], $fontColor["g"], $fontColor["b"]); $this->pdf->SetFont($font, $fontStyle, $fontSize); //set position if ($position == "absolute") { $currentX = $left; $currentY = $this->pdf->bMargin - $top; } else { if ($align == "R") { $currentX = $this->pdf->w - $this->pdf->rMargin - $contentLength - 3; $currentY = $this->pdf->bMargin; } elseif ($align == "L") { $currentX = $this->pdf->lMargin; $currentY = $this->pdf->bMargin; } elseif ($align == "C") { $currentX = ($this->pdf->w - $this->pdf->lMargin - $this->pdf->rMargin - $contentLength) / 2; $currentY = $this->pdf->bMargin; } else { $currentX = $this->pdf->GetX() + $left; $currentY = $this->pdf->bMargin; //$currentY = $this->pdf->GetY() + $top; } } $this->pdf->SetXY($currentX, -$currentY); // data if (empty($content)) { $content = $paragraph->content; } $this->pdf->MultiCell($width, $lineHeight, $content, $border, $textalign, $fill); } return true; }
/** * Search the styles information and put them. * * @return void */ private function _setStyle() { $fontStyle = ''; $fontColor = null; $font = null; $fontSize = null; //$indentSetted = false; $count = count($this->styleStack); for ($i = $count - 1; $i >= 0; $i--) { if (empty($fontColor) && isset($this->styleStack[$i]['color'])) { $fontColor = $this->styleStack[$i]['color']; } if (empty($font) && isset($this->styleStack[$i]['font'])) { $font = $this->styleStack[$i]['font']; } if (empty($fontSize) && isset($this->styleStack[$i]['font-size'])) { $fontSize = $this->styleStack[$i]['font-size']; } if (isset($this->styleStack[$i]['font-style']) && !empty($this->styleStack[$i]['font-style'])) { if (false !== strpos($fontStyle, trim($this->styleStack[$i]['font-style']))) { continue; } $fontStyle .= trim($this->styleStack[$i]['font-style']); } } $this->pdf->setFont($font, $fontStyle, $fontSize); $fontColor = Xml2Pdf::convertColor($fontColor); $this->pdf->setTextColor($fontColor['r'], $fontColor['g'], $fontColor['b']); }
/** * Render the line. * * @return void */ public function render() { if (!$this->columnsWidth) { // première ligne, on calcule la largeur des colonnes. $this->_calculColumnsWidth(); } $columnsProperties = array('font', 'fontSize', 'fontStyle', 'fontColor', 'fill', 'fillColor', 'border', 'borderColor', 'textAlign', 'lineHeight'); // paramétrage des colonnes de la ligne $columnsWidth = array_reverse($this->columnsWidth); foreach ($this->columns as $column) { $height = 0; // définies les propriétés non définie de la colonne foreach ($columnsProperties as $property) { if (!isset($column->{$property})) { $column->{$property} = $this->{$property}; } } $column->width = array_pop($columnsWidth); // positionne les infos de police et couleur $borderColor = Xml2Pdf::convertColor($this->borderColor); $this->pdf->SetDrawColor($borderColor["r"], $borderColor["g"], $borderColor["b"]); $fillColor = Xml2Pdf::convertColor($this->fillColor); $this->pdf->SetFillColor($fillColor["r"], $fillColor["g"], $fillColor["b"]); $fontColor = Xml2Pdf::convertColor($this->fontColor); $this->pdf->setTextColor($fontColor["r"], $fontColor["g"], $fontColor["b"]); $this->pdf->SetFont($this->font, $this->fontStyle, $this->fontSize); } // calcule la hauteur de la ligne $this->_calculRowHeight(); if ($this->pdf->getY() + $this->height >= $this->pdf->fh - $this->pdf->bMargin) { $this->pdf->AddPage(); //@todo if in th and tt exist write tt } // affiche les colonnes foreach ($this->columns as $column) { $this->_renderColumn($column); } // positionne le curseur pour la ligne suivante $this->pdf->Ln($this->height); $this->pdf->setX($this->table->left); }
/** * Reset header values. * * @return void */ private function _resetValues() { $dc = array(); // drawColor $fc = array(); // fillColor $dc = Xml2Pdf::convertColor($this->borderColor); $fc = Xml2Pdf::convertColor($this->fillColor); $this->pdf->SetDrawColor($dc['r'], $dc['g'], $dc['b']); $this->pdf->SetFillColor($fc['r'], $fc['g'], $fc['b']); $color = array(); $color = Xml2Pdf::convertColor($this->fontColor); $this->pdf->SetTextColor($color['r'], $color['g'], $color['b']); $this->pdf->SetFont($this->font, $this->fontStyle, $this->fontSize); }
/** * Render the paragraph or add it to the parent tag. * * @return void */ public function close() { if ($this->parent) { $this->parent->elements[] = $this; return; } // calc the paragraph left and top using : align, position, left and top if ($this->position == 'absolute') { $x = $this->left; $y = $this->top; } else { $pageWidth = 210 - $this->pdf->lMargin - $this->pdf->rMargin; if ($this->left) { $x = $this->pdf->GetX() + $this->left; } elseif ($this->align) { if ($this->align == 'L') { $x = $this->pdf->lMargin; } elseif ($this->align == 'R') { $x = $pageWidth - $this->width + $this->pdf->rMargin; } elseif ($this->align == 'C') { $x = ($pageWidth - $this->width) / 2 + $this->pdf->lMargin; } } else { $x = $this->pdf->GetX(); } if ($this->top) { $y = $this->pdf->GetY() + $this->top; } else { $y = $this->pdf->GetY(); } } if (!$x) { $x = $this->pdf->lMargin; } if (!$y) { $y = $this->pdf->tMargin; } $this->pdf->SetXY($x, $y); // set the paragraph font, fill, border and draw params $borderColor = Xml2Pdf::convertColor($this->borderColor); $this->pdf->SetDrawColor($borderColor['r'], $borderColor['g'], $borderColor['b']); $fillColor = Xml2Pdf::convertColor($this->fillColor); $this->pdf->SetFillColor($fillColor['r'], $fillColor['g'], $fillColor['b']); $fontColor = Xml2Pdf::convertColor($this->fontColor); $this->pdf->setTextColor($fontColor['r'], $fontColor['g'], $fontColor['b']); $this->pdf->setFont($this->font, $this->fontStyle, $this->fontSize); // write the content $this->pdf->multicell($this->width, $this->lineHeight, $this->content, $this->border, $this->textAlign, $this->fill); }
/** * render the cell. * * @return void */ public function render() { // set colors $borderColor = Xml2Pdf::convertColor($this->borderColor); $this->pdf->SetDrawColor($borderColor["r"], $borderColor["g"], $borderColor["b"]); $fillColor = Xml2Pdf::convertColor($this->fillColor); $this->pdf->SetFillColor($fillColor["r"], $fillColor["g"], $fillColor["b"]); $fontColor = Xml2Pdf::convertColor($this->fontColor); $this->pdf->setTextColor($fontColor["r"], $fontColor["g"], $fontColor["b"]); $this->pdf->SetFont($this->font, $this->fontStyle, $this->fontSize); $x = $this->pdf->GetX(); $y = $this->pdf->GetY(); if ($this->fill || $this->border) { $mode = ''; if ($this->fill) { $mode .= 'F'; } if ($this->border) { $mode .= 'D'; } $this->pdf->Rect($x, $y, $this->width, $this->height, $mode); } $this->pdf->MultiCell($this->width, $this->lineHeight, $this->content, 0, $this->textAlign, 0); //Put the position to the right of the cell $this->pdf->SetXY($x + $this->width, $y); }
public function render() { if ($this->end && $this->end < $this->pdf->PageNo() || $this->start > $this->pdf->PageNo()) { return false; } $this->pdf->SetFont($this->font, $this->fontStyle, $this->fontSize); $fontColor = Xml2Pdf::convertColor($this->fontColor); $this->pdf->SetTextColor($fontColor['r'], $fontColor['g'], $fontColor['b']); if (!$this->left) { $this->left = $this->pdf->getX(); } if (!$this->top) { $this->top = $this->pdf->getY(); } $initial = $this->pdf->angle; $this->pdf->Rotate($this->rotation, $this->left, $this->top); $this->pdf->Text($this->left, $this->top, $this->content); $this->pdf->Rotate($initial); }
/** * Reset all values. * * Reset all values using the curent page values. * * @return void * @access public */ public function resetAllValues() { $dc = Xml2Pdf::convertColor($this->pageDrawColor); $fc = Xml2Pdf::convertColor($this->pageFillColor); $this->SetDrawColor($dc["r"], $dc["g"], $dc["b"]); $this->SetFillColor($fc["r"], $fc["g"], $fc["b"]); $this->resetFont(); }