public function getFontColor() { if (count($this->fontColor) == 0) { $this->setFontColor(0, 0, 0); } return DataUtils::get_hex_rgb($this->fontColor); }
public function write() { $color = DataUtils::get_rgb_color($this->strokeColor); $this->componentPdfWriter->SetDrawColor($color["r"] * 255, $color["g"] * 255, $color["b"] * 255); $this->componentPdfWriter->SetLineWidth($this->width); $this->componentPdfWriter->Line($this->getPageX(), $this->getPageY(), $this->getPageX(), $this->getPageY() + $this->height); }
public function write() { $backgroundColor = DataUtils::get_rgb_color($this->backgroundColor); $borderColor = DataUtils::get_rgb_color($this->borderColor); $this->componentPdfWriter->SetFillColor($backgroundColor['r'], $backgroundColor['g'], $backgroundColor['b']); $this->componentPdfWriter->SetDrawColor($borderColor['r'], $borderColor['g'], $borderColor['b']); $this->componentPdfWriter->Rect($this->getPageX(), $this->getPageY(), $this->width, $this->height, "DF"); parent::write(); }
public function PrintPDF($obj, $fileName = "") { if ($fileName == "") { $fileName = DataUtils::getOutputFileName(); } $path = WebOrbServicesPath . BASE_PDF_SERVICE_PATH . "PDF\\pdf_files\\"; Log::log(LoggingConstants::MYDEBUG, "Save start"); PDFUtil::saveDocument($obj, $path, $fileName); Log::log(LoggingConstants::MYDEBUG, "Save finished"); return self::DOWNLOAD_URL . $fileName; }
public function getContent() { if ($this->id == null || $this->id == '') { $this->id = DataUtils::getRandomString(10); } Log::log(LoggingConstants::MYDEBUG, "getContent: " . $this->id); if ($this->document->images == null || $this->document->images[$this->id] == null) { $this->document->images[$this->id] = DataUtils::getImage($this->source); } return $this->document->images[$this->id]; }
public function write() { $backgroundColor = DataUtils::get_rgb_color($this->backgroundColor); $borderColor = DataUtils::get_rgb_color($this->borderColor); $this->componentPdfWriter->SetFillColor(255); $this->componentPdfWriter->SetDrawColor(0); $this->componentPdfWriter->Rect($this->getPageX(), $this->getPageY(), $this->width, $this->height, "DF"); $this->value = $this->label; parent::write(); if ($this->isSubmit) { $this->componentPdfWriter->Link($this->getPageX(), $this->getPageY(), $this->width, $this->height, $this->url); } }
public function initComponent($pdfWriter, $pdfDocument, $baseX, $baseY, $marginTop, $marginLeft, $marginRight, $marginBottom, $parentWidth, $parentHeight) { /*PDFMetadata*/ $metadata = $pdfDocument->metadata; if ($metadata != null) { /*Property[]*/ $properties = $metadata->getPropertiesByTarget($this->dataField); if (count($properties) != 0) { foreach ($properties as $property) { DataUtils::setValue($this, $property->name, (string) $property->value); } } } }
private function populate($object, $element) { $i = 0; $attributes = $element->attributes; while ($attributes->item($i) != null) { $node = $attributes->item($i); /*String*/ $attrName = $node->nodeName; /*String*/ $attrValue = $node->nodeValue; DataUtils::setValue($object, $attrName, $attrValue); $i++; } }
public function write() { parent::write(); if ($this->value == null || strlen($this->value) == 0 || $this->fontSize == 0) { return; } $font = $this->getFont(); $font->setFont($this->componentPdfWriter); $this->componentPdfWriter->SetXY($this->getPageX(), $this->getPageY()); $val = DataUtils::getValue($this->value); if ($this->width == 0) { $this->width = $this->componentPdfWriter->GetStringWidth($val); } $this->componentPdfWriter->MultiCell($this->width + 6, $this->fontSize + 6, $val, 0, "L", false); }
public static function build($value) { /*DocumentBuilder*/ $builder = new DocumentBuilder(); if (DataUtils::valueIsMethod($value)) { return $builder->buildOnMethod($value); } else { if (DataUtils::valueIsLink($value)) { return $builder->buildOnURLTemplate($value); } else { if (DataUtils::valueIsFile($value)) { return $builder->buildOnFileTemplate($value); } else { return $builder->buildOnString($value); } } } }
protected function generateFromArray($array) { if ($array == null) { $array = $this->dataProvider; } parent::generateFromArray($array); if (count($this->dataProviderList) == 0) { throw new Exception("DataProvider is empty"); } else { if ($this->dataProviderList[0][DataUtils::$METHOD_WORD] != null) { if (DataUtils::valueIsMethod($this->dataProviderList[0][DataUtils::$METHOD_WORD])) { $this->generateFromString($this->dataProviderList[0][DataUtils::$METHOD_WORD]); } else { $this->generateFromString(DataUtils::$METHOD_CODE + $this->dataProviderList[0][DataUtils::$METHOD_WORD]); } } else { foreach ($this->dataProviderList as $key => $val) { if (DataUtils::valueIsMethod($val)) { $this->generateFromString($val); } } } } }
/** * If income value is method function returns method invocation result * another way function return income value * * @param value * @return {@link Object} * @throws DocumentException */ public static function getValue($value) { /*Object*/ $result = $value; if (is_string($value)) { if (self::valueIsMethod($value)) { $dataUtils = new DataUtils(); $result = $dataUtils->getMethodResult($value); } } return $result; }
/** * Generate data provider array (dataProviderList) based on Object array * * @param array income Object array each member of it could be * HashMap, Object or Object[] * @throws DocumentException */ protected function generateFromArray($array) { if (count($array) == 1) { foreach ($array as $val) { if (DataUtils::valueIsMethod($val)) { $this->generateFromString($val); return; } break; } } $this->dataProviderList = array(); for ($i = 0; $i < count($array); $i++) { $item = array(); $this->populateRow($item, $array[$i]); $this->dataProviderList[] = $item; } }
public function getColumnWidth(DataGridColumn $column) { $lenths = array(); foreach ($this->dataProviderList as $data) { $lenths[] = strlen(DataUtils::getValue($data[$column->dataField])) * $this->fontSize; } return max($lenths); }
public function initComponent(Document $pdfDocument, PDF $pdfWriter, $baseX, $baseY, $marginTop, $marginLeft, $marginRight, $marginBottom, $parentWidth, $parentHeight) { //-------------------------------base options------------------------------- Log::log(LoggingConstants::MYDEBUG, "INIT COMPONENT: " . get_class($this) . " : " . $this->id); if ($pdfDocument != null) { $this->document = $pdfDocument; } if ($pdfWriter != null) { $this->componentPdfWriter = $pdfWriter; } //-------------------------------top, left, right, bottom------------------------------- if ($this->top != -1) { $this->y = $this->top; } // +marginTop + baseY; if ($this->left != -1) { $this->x = $this->left; } // +marginLeft + baseX; if ($this->right != -1) { if ($this->left != -1) { $this->width = $parentWidth - $this->x - $this->right; } else { $this->x = $parentWidth - $this->right - $this->width; } // - marginRight; } if ($this->bottom != -1) { if ($this->top != -1) { $this->height = $parentHeight - $this->y - $this->bottom; } else { $this->y = $parentHeight - $this->bottom - $this->height; } // -marginBottom; } //-------------------------------base coords------------------------------- if ($this->baseX != 0) { $this->x += $this->baseX; } if ($this->baseY != 0) { $this->y += $this->baseY; } //-------------------------------margins------------------------------- if ($marginTop != 0) { $this->y += $marginTop; } if ($marginLeft != 0) { $this->x += $marginLeft; } if ($this->right != -1) { if ($this->left != -1) { $this->width -= $marginLeft + $marginRight; } else { $this->x -= $marginRight; } } if ($this->bottom != -1) { if ($this->top != -1) { $this->height -= $marginTop + $marginBottom; } else { $this->y -= $marginBottom; } } //-------------------------------Meatadata------------------------------- if ($this->id != null && $this->id != "") { /*PDFMetadata*/ $metadata = $pdfDocument->metadata; if ($metadata != null) { /*Property[]*/ $properties = $metadata->getPropertiesByTarget($this->id); if (count($properties) != 0) { foreach ($properties as $property) { if ($property->name == Property::$SHOW_ON_ALL_PAGES) { $this->onEachPage = true; } else { if ($property->name == Property::$EXTEND_TO_PAGEBOTTOM) { $this->height = $parentHeight - $this->y - $marginBottom; if ($this->bottom != -1) { $this->height -= $this->bottom; } } else { if ($property->value == null || $property->value == "") { $property->value = true; } DataUtils::setValue($this, $property->name, $property->value); } } } } } } }