/** * @return Image */ protected function initialize() { $this->image = ImageManagerStatic::canvas(2408, 3508, '#fff'); $this->image->polygon([0, 0, 0, 400, 980, 400, 1250, 0], function (AbstractShape $shape) { $shape->background($this->template->getFontColor()); }); // Draw header $this->image->polygon([1250, 0, 980, 400, $this->image->getWidth(), 400, $this->image->getWidth(), 0], function (AbstractShape $shape) { $shape->background($this->template->getPrimaryColor()); }); $this->image->polygon([0, 400, 0, 425, 675, 425, 755, 480, 800, 400], function (AbstractShape $shape) { $shape->background($this->template->getPrimaryColor()); }); $color = $this->template->getPrimaryColor(); $color[0] = $color[0] + 90; if ($color[0] > 255) { $color[0] = 255; } $this->image->polygon([800, 400, 755, 480, 820, 500, 890, 400], function (AbstractShape $shape) use($color) { $shape->background($color); }); $this->image->polygon([890, 400, 870, 425, 970, 425, 990, 400], function (AbstractShape $shape) { $shape->background($this->template->getPrimaryColor()); }); // Company address (Left header) if ($this->template->getLogo()) { $size = @getimagesize($this->template->getLogo()); if ($size) { $this->image->insert($this->template->getLogo(), 'top-left', (int) ((980 - $size[0]) / 2), (int) ((186 - $size[1]) / 2)); } } $y = isset($size) ? 220 : 120; $this->image->text($this->company->getZip() . ' ' . $this->company->getTown(), 450, $y, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('right'); $font->size(27); }); $this->image->text($this->company->getAddress(), 450, $y + 50, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('right'); $font->size(27); }); $this->image->text($this->company->getCountry(), 450, $y + 100, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('right'); $font->size(27); }); $multiplier = 0; if ($this->company->getTin()) { $this->image->text(Strings::upper($this->translate('vat')) . ': ' . $this->company->getTin(), 520, $y + $multiplier * 50, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('left'); $font->size(27); }); $multiplier++; } if ($this->company->getVaTin()) { $this->image->text(Strings::upper($this->translate('vaTin')) . ': ' . $this->company->getVaTin(), 520, $y + $multiplier * 50, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('left'); $font->size(27); }); $multiplier++; } $this->image->text($this->company->hasTax() ? $this->translate('taxPay') : $this->translate('notTax'), 520, $y + $multiplier * 50, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('left'); $font->size(27); }); // Company name or full name $this->image->text($this->company->getName(), 1775, 100, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('center'); $font->size(35); }); // Payment informations $this->image->text(Strings::upper($this->translate('paymentData')), 1500, 500, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getPrimaryColor()); $font->align('left'); $font->valign('top'); $font->size(65); }); $this->image->polygon([1450, 580, 1450, 620, 1480, 590, $this->image->getWidth(), 590, $this->image->getWidth(), 580], function (AbstractShape $shape) { $shape->background($this->template->getPrimaryColor()); }); $this->itemsHeader(); $this->image->rectangle(0, $this->image->getHeight() - 80, $this->image->getWidth(), $this->image->getHeight(), function (AbstractShape $shape) { $shape->background($this->template->getFontColor()); }); $this->image->text($this->template->getFooter(), $this->image->getWidth() / 2, $this->image->getHeight() - 40, function (Font $font) { $font->file($this->template->getFont()); $font->color($this->template->getColorOdd()); $font->align('center'); $font->size(24); $font->valign('center'); }); }