Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Abstract.php
Go to the documentation of this file.
1 <?php
22 #require_once 'Zend/Pdf/Canvas/Interface.php';
23 
25 #require_once 'Zend/Pdf/Element.php';
26 #require_once 'Zend/Pdf/Element/Array.php';
27 #require_once 'Zend/Pdf/Element/String/Binary.php';
28 #require_once 'Zend/Pdf/Element/Boolean.php';
29 #require_once 'Zend/Pdf/Element/Dictionary.php';
30 #require_once 'Zend/Pdf/Element/Name.php';
31 #require_once 'Zend/Pdf/Element/Null.php';
32 #require_once 'Zend/Pdf/Element/Numeric.php';
33 #require_once 'Zend/Pdf/Element/String.php';
34 #require_once 'Zend/Pdf/Resource/GraphicsState.php';
35 #require_once 'Zend/Pdf/Resource/Font.php';
36 #require_once 'Zend/Pdf/Resource/Image.php';
37 
38 
48 {
54  protected $_contents = '';
55 
61  protected $_font = null;
62 
68  protected $_fontSize;
69 
75  protected $_style = null;
76 
77 
83  protected $_saveCount = 0;
84 
85 
91  abstract protected function _addProcSet($procSetName);
92 
105  abstract protected function _attachResource($type, Zend_Pdf_Resource $resource);
106 
120  public function drawCanvas(Zend_Pdf_Canvas_Interface $canvas, $x1, $y1, $x2 = null, $y2 = null)
121  {
122  $this->saveGS();
123 
124  $this->translate($x1, $y1);
125 
126  if ($x2 === null) {
127  $with = $canvas->getWidth();
128  } else {
129  $with = $x2 - $x1;
130  }
131  if ($y2 === null) {
132  $height = $canvas->getHeight();
133  } else {
134  $height = $y2 - $y1;
135  }
136 
137  $this->clipRectangle(0, 0, $with, $height);
138 
139  if ($x2 !== null || $y2 !== null) {
140  // Drawn canvas has to be scaled.
141  if ($x2 !== null) {
142  $xScale = $with/$canvas->getWidth();
143  } else {
144  $xScale = 1;
145  }
146 
147  if ($y2 !== null) {
148  $yScale = $height/$canvas->getHeight();
149  } else {
150  $yScale = 1;
151  }
152 
153  $this->scale($xScale, $yScale);
154  }
155 
156  $contentsToDraw = $canvas->getContents();
159  $this->restoreGS();
160 
161  return $this;
162  }
163 
170  public function setFillColor(Zend_Pdf_Color $color)
171  {
172  $this->_addProcSet('PDF');
173  $this->_contents .= $color->instructions(false);
174 
175  return $this;
176  }
177 
184  public function setLineColor(Zend_Pdf_Color $color)
185  {
186  $this->_addProcSet('PDF');
187  $this->_contents .= $color->instructions(true);
188 
189  return $this;
190  }
191 
198  public function setLineWidth($width)
199  {
200  $this->_addProcSet('PDF');
201  $widthObj = new Zend_Pdf_Element_Numeric($width);
202  $this->_contents .= $widthObj->toString() . " w\n";
203 
204  return $this;
205  }
206 
218  public function setLineDashingPattern($pattern, $phase = 0)
219  {
220  $this->_addProcSet('PDF');
221 
222  #require_once 'Zend/Pdf/Page.php';
224  $pattern = array();
225  $phase = 0;
226  }
227 
228  $dashPattern = new Zend_Pdf_Element_Array();
229  $phaseEleemnt = new Zend_Pdf_Element_Numeric($phase);
230 
231  foreach ($pattern as $dashItem) {
232  $dashElement = new Zend_Pdf_Element_Numeric($dashItem);
233  $dashPattern->items[] = $dashElement;
234  }
235 
236  $this->_contents .= $dashPattern->toString() . ' '
237  . $phaseEleemnt->toString() . " d\n";
238 
239  return $this;
240  }
241 
249  public function setFont(Zend_Pdf_Resource_Font $font, $fontSize)
250  {
251  $this->_addProcSet('Text');
252  $fontName = $this->_attachResource('Font', $font);
253 
254  $this->_font = $font;
255  $this->_fontSize = $fontSize;
256 
257  $fontNameObj = new Zend_Pdf_Element_Name($fontName);
258  $fontSizeObj = new Zend_Pdf_Element_Numeric($fontSize);
259  $this->_contents .= $fontNameObj->toString() . ' ' . $fontSizeObj->toString() . " Tf\n";
260 
261  return $this;
262  }
263 
270  public function setStyle(Zend_Pdf_Style $style)
271  {
272  $this->_addProcSet('Text');
273  $this->_addProcSet('PDF');
274  if ($style->getFont() !== null) {
275  $this->setFont($style->getFont(), $style->getFontSize());
276  }
277  $this->_contents .= $style->instructions($this->_dictionary->Resources);
278 
279  $this->_style = $style;
280 
281  return $this;
282  }
283 
289  public function getFont()
290  {
291  return $this->_font;
292  }
293 
299  public function getFontSize()
300  {
301  return $this->_fontSize;
302  }
303 
309  public function getStyle()
310  {
311  return $this->_style;
312  }
313 
323  public function saveGS()
324  {
325  $this->_saveCount++;
326 
327  $this->_addProcSet('PDF');
328  $this->_contents .= " q\n";
329 
330  return $this;
331  }
332 
339  public function restoreGS()
340  {
341  if ($this->_saveCount-- <= 0) {
342  #require_once 'Zend/Pdf/Exception.php';
343  throw new Zend_Pdf_Exception('Restoring graphics state which is not saved');
344  }
345  $this->_contents .= " Q\n";
346 
347  return $this;
348  }
349 
364  public function setAlpha($alpha, $mode = 'Normal')
365  {
366  $this->_addProcSet('Text');
367  $this->_addProcSet('PDF');
368 
369  $graphicsState = new Zend_Pdf_Resource_GraphicsState();
370 
371  $graphicsState->setAlpha($alpha, $mode);
372  $gStateName = $this->_attachResource('ExtGState', $graphicsState);
373 
374  $gStateNameObject = new Zend_Pdf_Element_Name($gStateName);
375  $this->_contents .= $gStateNameObject->toString() . " gs\n";
376 
377  return $this;
378  }
379 
390  public function clipCircle($x, $y, $radius, $startAngle = null, $endAngle = null)
391  {
392  $this->clipEllipse($x - $radius, $y - $radius,
393  $x + $radius, $y + $radius,
394  $startAngle, $endAngle);
395 
396  return $this;
397  }
398 
416  public function clipEllipse($x1, $y1, $x2, $y2, $startAngle = null, $endAngle = null)
417  {
418  $this->_addProcSet('PDF');
419 
420  if ($x2 < $x1) {
421  $temp = $x1;
422  $x1 = $x2;
423  $x2 = $temp;
424  }
425  if ($y2 < $y1) {
426  $temp = $y1;
427  $y1 = $y2;
428  $y2 = $temp;
429  }
430 
431  $x = ($x1 + $x2)/2.;
432  $y = ($y1 + $y2)/2.;
433 
434  $xC = new Zend_Pdf_Element_Numeric($x);
435  $yC = new Zend_Pdf_Element_Numeric($y);
436 
437  if ($startAngle !== null) {
438  if ($startAngle != 0) { $startAngle = fmod($startAngle, M_PI*2); }
439  if ($endAngle != 0) { $endAngle = fmod($endAngle, M_PI*2); }
440 
441  if ($startAngle > $endAngle) {
442  $endAngle += M_PI*2;
443  }
444 
445  $clipPath = $xC->toString() . ' ' . $yC->toString() . " m\n";
446  $clipSectors = (int)ceil(($endAngle - $startAngle)/M_PI_4);
447  $clipRadius = max($x2 - $x1, $y2 - $y1);
448 
449  for($count = 0; $count <= $clipSectors; $count++) {
450  $pAngle = $startAngle + ($endAngle - $startAngle)*$count/(float)$clipSectors;
451 
452  $pX = new Zend_Pdf_Element_Numeric($x + cos($pAngle)*$clipRadius);
453  $pY = new Zend_Pdf_Element_Numeric($y + sin($pAngle)*$clipRadius);
454  $clipPath .= $pX->toString() . ' ' . $pY->toString() . " l\n";
455  }
456 
457  $this->_contents .= $clipPath . "h\nW\nn\n";
458  }
459 
460  $xLeft = new Zend_Pdf_Element_Numeric($x1);
461  $xRight = new Zend_Pdf_Element_Numeric($x2);
462  $yUp = new Zend_Pdf_Element_Numeric($y2);
463  $yDown = new Zend_Pdf_Element_Numeric($y1);
464 
465  $xDelta = 2*(M_SQRT2 - 1)*($x2 - $x1)/3.;
466  $yDelta = 2*(M_SQRT2 - 1)*($y2 - $y1)/3.;
467  $xr = new Zend_Pdf_Element_Numeric($x + $xDelta);
468  $xl = new Zend_Pdf_Element_Numeric($x - $xDelta);
469  $yu = new Zend_Pdf_Element_Numeric($y + $yDelta);
470  $yd = new Zend_Pdf_Element_Numeric($y - $yDelta);
471 
472  $this->_contents .= $xC->toString() . ' ' . $yUp->toString() . " m\n"
473  . $xr->toString() . ' ' . $yUp->toString() . ' '
474  . $xRight->toString() . ' ' . $yu->toString() . ' '
475  . $xRight->toString() . ' ' . $yC->toString() . " c\n"
476  . $xRight->toString() . ' ' . $yd->toString() . ' '
477  . $xr->toString() . ' ' . $yDown->toString() . ' '
478  . $xC->toString() . ' ' . $yDown->toString() . " c\n"
479  . $xl->toString() . ' ' . $yDown->toString() . ' '
480  . $xLeft->toString() . ' ' . $yd->toString() . ' '
481  . $xLeft->toString() . ' ' . $yC->toString() . " c\n"
482  . $xLeft->toString() . ' ' . $yu->toString() . ' '
483  . $xl->toString() . ' ' . $yUp->toString() . ' '
484  . $xC->toString() . ' ' . $yUp->toString() . " c\n"
485  . "h\nW\nn\n";
486 
487  return $this;
488  }
489 
498  public function clipPolygon($x, $y, $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING)
499  {
500  $this->_addProcSet('PDF');
501 
502  $firstPoint = true;
503  foreach ($x as $id => $xVal) {
504  $xObj = new Zend_Pdf_Element_Numeric($xVal);
505  $yObj = new Zend_Pdf_Element_Numeric($y[$id]);
506 
507  if ($firstPoint) {
508  $path = $xObj->toString() . ' ' . $yObj->toString() . " m\n";
509  $firstPoint = false;
510  } else {
511  $path .= $xObj->toString() . ' ' . $yObj->toString() . " l\n";
512  }
513  }
514 
515  $this->_contents .= $path;
516 
517  if ($fillMethod == Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) {
518  $this->_contents .= " h\n W\nn\n";
519  } else {
520  // Even-Odd fill method.
521  $this->_contents .= " h\n W*\nn\n";
522  }
523 
524  return $this;
525  }
526 
536  public function clipRectangle($x1, $y1, $x2, $y2)
537  {
538  $this->_addProcSet('PDF');
539 
540  $x1Obj = new Zend_Pdf_Element_Numeric($x1);
541  $y1Obj = new Zend_Pdf_Element_Numeric($y1);
542  $widthObj = new Zend_Pdf_Element_Numeric($x2 - $x1);
543  $height2Obj = new Zend_Pdf_Element_Numeric($y2 - $y1);
544 
545  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '
546  . $widthObj->toString() . ' ' . $height2Obj->toString() . " re\n"
547  . " W\nn\n";
548 
549  return $this;
550  }
551 
552 // ------------------------------------------------------------------------------------------
577  public function drawCircle($x, $y, $radius, $param4 = null, $param5 = null, $param6 = null)
578  {
579  $this->drawEllipse($x - $radius, $y - $radius,
580  $x + $radius, $y + $radius,
581  $param4, $param5, $param6);
582 
583  return $this;
584  }
585 
606  public function drawEllipse($x1, $y1, $x2, $y2, $param5 = null, $param6 = null, $param7 = null)
607  {
608  if ($param5 === null) {
609  // drawEllipse($x1, $y1, $x2, $y2);
610  $startAngle = null;
612  } else if ($param6 === null) {
613  // drawEllipse($x1, $y1, $x2, $y2, $fillType);
614  $startAngle = null;
615  $fillType = $param5;
616  } else {
617  // drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
618  // drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle, $fillType);
619  $startAngle = $param5;
620  $endAngle = $param6;
621 
622  if ($param7 === null) {
624  } else {
625  $fillType = $param7;
626  }
627  }
628 
629  $this->_addProcSet('PDF');
630 
631  if ($x2 < $x1) {
632  $temp = $x1;
633  $x1 = $x2;
634  $x2 = $temp;
635  }
636  if ($y2 < $y1) {
637  $temp = $y1;
638  $y1 = $y2;
639  $y2 = $temp;
640  }
641 
642  $x = ($x1 + $x2)/2.;
643  $y = ($y1 + $y2)/2.;
644 
645  $xC = new Zend_Pdf_Element_Numeric($x);
646  $yC = new Zend_Pdf_Element_Numeric($y);
647 
648  if ($startAngle !== null) {
649  if ($startAngle != 0) { $startAngle = fmod($startAngle, M_PI*2); }
650  if ($endAngle != 0) { $endAngle = fmod($endAngle, M_PI*2); }
651 
652  if ($startAngle > $endAngle) {
653  $endAngle += M_PI*2;
654  }
655 
656  $clipPath = $xC->toString() . ' ' . $yC->toString() . " m\n";
657  $clipSectors = (int)ceil(($endAngle - $startAngle)/M_PI_4);
658  $clipRadius = max($x2 - $x1, $y2 - $y1);
659 
660  for($count = 0; $count <= $clipSectors; $count++) {
661  $pAngle = $startAngle + ($endAngle - $startAngle)*$count/(float)$clipSectors;
662 
663  $pX = new Zend_Pdf_Element_Numeric($x + cos($pAngle)*$clipRadius);
664  $pY = new Zend_Pdf_Element_Numeric($y + sin($pAngle)*$clipRadius);
665  $clipPath .= $pX->toString() . ' ' . $pY->toString() . " l\n";
666  }
667 
668  $this->_contents .= "q\n" . $clipPath . "h\nW\nn\n";
669  }
670 
671  $xLeft = new Zend_Pdf_Element_Numeric($x1);
672  $xRight = new Zend_Pdf_Element_Numeric($x2);
673  $yUp = new Zend_Pdf_Element_Numeric($y2);
674  $yDown = new Zend_Pdf_Element_Numeric($y1);
675 
676  $xDelta = 2*(M_SQRT2 - 1)*($x2 - $x1)/3.;
677  $yDelta = 2*(M_SQRT2 - 1)*($y2 - $y1)/3.;
678  $xr = new Zend_Pdf_Element_Numeric($x + $xDelta);
679  $xl = new Zend_Pdf_Element_Numeric($x - $xDelta);
680  $yu = new Zend_Pdf_Element_Numeric($y + $yDelta);
681  $yd = new Zend_Pdf_Element_Numeric($y - $yDelta);
682 
683  $this->_contents .= $xC->toString() . ' ' . $yUp->toString() . " m\n"
684  . $xr->toString() . ' ' . $yUp->toString() . ' '
685  . $xRight->toString() . ' ' . $yu->toString() . ' '
686  . $xRight->toString() . ' ' . $yC->toString() . " c\n"
687  . $xRight->toString() . ' ' . $yd->toString() . ' '
688  . $xr->toString() . ' ' . $yDown->toString() . ' '
689  . $xC->toString() . ' ' . $yDown->toString() . " c\n"
690  . $xl->toString() . ' ' . $yDown->toString() . ' '
691  . $xLeft->toString() . ' ' . $yd->toString() . ' '
692  . $xLeft->toString() . ' ' . $yC->toString() . " c\n"
693  . $xLeft->toString() . ' ' . $yu->toString() . ' '
694  . $xl->toString() . ' ' . $yUp->toString() . ' '
695  . $xC->toString() . ' ' . $yUp->toString() . " c\n";
696 
697  switch ($fillType) {
699  $this->_contents .= " B*\n";
700  break;
702  $this->_contents .= " f*\n";
703  break;
705  $this->_contents .= " S\n";
706  break;
707  }
708 
709  if ($startAngle !== null) {
710  $this->_contents .= "Q\n";
711  }
712 
713  return $this;
714  }
715 
726  public function drawImage(Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2)
727  {
728  $this->_addProcSet('PDF');
729 
730  $imageName = $this->_attachResource('XObject', $image);
731  $imageNameObj = new Zend_Pdf_Element_Name($imageName);
732 
733  $x1Obj = new Zend_Pdf_Element_Numeric($x1);
734  $y1Obj = new Zend_Pdf_Element_Numeric($y1);
735  $widthObj = new Zend_Pdf_Element_Numeric($x2 - $x1);
736  $heightObj = new Zend_Pdf_Element_Numeric($y2 - $y1);
737 
738  $this->_contents .= "q\n"
739  . '1 0 0 1 ' . $x1Obj->toString() . ' ' . $y1Obj->toString() . " cm\n"
740  . $widthObj->toString() . ' 0 0 ' . $heightObj->toString() . " 0 0 cm\n"
741  . $imageNameObj->toString() . " Do\n"
742  . "Q\n";
743 
744  return $this;
745  }
746 
757  public function drawLayoutBox($box, $x, $y)
758  {
760  return $this;
761  }
762 
772  public function drawLine($x1, $y1, $x2, $y2)
773  {
774  $this->_addProcSet('PDF');
775 
776  $x1Obj = new Zend_Pdf_Element_Numeric($x1);
777  $y1Obj = new Zend_Pdf_Element_Numeric($y1);
778  $x2Obj = new Zend_Pdf_Element_Numeric($x2);
779  $y2Obj = new Zend_Pdf_Element_Numeric($y2);
780 
781  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " m\n"
782  . $x2Obj->toString() . ' ' . $y2Obj->toString() . " l\n S\n";
783 
784  return $this;
785  }
786 
801  public function drawPolygon($x, $y,
804  {
805  $this->_addProcSet('PDF');
806 
807  $firstPoint = true;
808  foreach ($x as $id => $xVal) {
809  $xObj = new Zend_Pdf_Element_Numeric($xVal);
810  $yObj = new Zend_Pdf_Element_Numeric($y[$id]);
811 
812  if ($firstPoint) {
813  $path = $xObj->toString() . ' ' . $yObj->toString() . " m\n";
814  $firstPoint = false;
815  } else {
816  $path .= $xObj->toString() . ' ' . $yObj->toString() . " l\n";
817  }
818  }
819 
820  $this->_contents .= $path;
821 
822  switch ($fillType) {
824  if ($fillMethod == Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) {
825  $this->_contents .= " b\n";
826  } else {
827  // Even-Odd fill method.
828  $this->_contents .= " b*\n";
829  }
830  break;
832  if ($fillMethod == Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) {
833  $this->_contents .= " h\n f\n";
834  } else {
835  // Even-Odd fill method.
836  $this->_contents .= " h\n f*\n";
837  }
838  break;
840  $this->_contents .= " S\n";
841  break;
842  }
843 
844  return $this;
845  }
846 
862  public function drawRectangle($x1, $y1, $x2, $y2, $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE)
863  {
864  $this->_addProcSet('PDF');
865 
866  $x1Obj = new Zend_Pdf_Element_Numeric($x1);
867  $y1Obj = new Zend_Pdf_Element_Numeric($y1);
868  $widthObj = new Zend_Pdf_Element_Numeric($x2 - $x1);
869  $height2Obj = new Zend_Pdf_Element_Numeric($y2 - $y1);
870 
871  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '
872  . $widthObj->toString() . ' ' . $height2Obj->toString() . " re\n";
873 
874  switch ($fillType) {
876  $this->_contents .= " B*\n";
877  break;
879  $this->_contents .= " f*\n";
880  break;
882  $this->_contents .= " S\n";
883  break;
884  }
885 
886  return $this;
887  }
888 
909  public function drawRoundedRectangle($x1, $y1, $x2, $y2, $radius,
911  {
912 
913  $this->_addProcSet('PDF');
914 
915  if(!is_array($radius)) {
916  $radius = array($radius, $radius, $radius, $radius);
917  } else {
918  for ($i = 0; $i < 4; $i++) {
919  if(!isset($radius[$i])) {
920  $radius[$i] = 0;
921  }
922  }
923  }
924 
925  $topLeftX = $x1;
926  $topLeftY = $y2;
927  $topRightX = $x2;
928  $topRightY = $y2;
929  $bottomRightX = $x2;
930  $bottomRightY = $y1;
931  $bottomLeftX = $x1;
932  $bottomLeftY = $y1;
933 
934  //draw top side
935  $x1Obj = new Zend_Pdf_Element_Numeric($topLeftX + $radius[0]);
936  $y1Obj = new Zend_Pdf_Element_Numeric($topLeftY);
937  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " m\n";
938  $x1Obj = new Zend_Pdf_Element_Numeric($topRightX - $radius[1]);
939  $y1Obj = new Zend_Pdf_Element_Numeric($topRightY);
940  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " l\n";
941 
942  //draw top right corner if needed
943  if ($radius[1] != 0) {
944  $x1Obj = new Zend_Pdf_Element_Numeric($topRightX);
945  $y1Obj = new Zend_Pdf_Element_Numeric($topRightY);
946  $x2Obj = new Zend_Pdf_Element_Numeric($topRightX);
947  $y2Obj = new Zend_Pdf_Element_Numeric($topRightY);
948  $x3Obj = new Zend_Pdf_Element_Numeric($topRightX);
949  $y3Obj = new Zend_Pdf_Element_Numeric($topRightY - $radius[1]);
950  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '
951  . $x2Obj->toString() . ' ' . $y2Obj->toString() . ' '
952  . $x3Obj->toString() . ' ' . $y3Obj->toString() . ' '
953  . " c\n";
954  }
955 
956  //draw right side
957  $x1Obj = new Zend_Pdf_Element_Numeric($bottomRightX);
958  $y1Obj = new Zend_Pdf_Element_Numeric($bottomRightY + $radius[2]);
959  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " l\n";
960 
961  //draw bottom right corner if needed
962  if ($radius[2] != 0) {
963  $x1Obj = new Zend_Pdf_Element_Numeric($bottomRightX);
964  $y1Obj = new Zend_Pdf_Element_Numeric($bottomRightY);
965  $x2Obj = new Zend_Pdf_Element_Numeric($bottomRightX);
966  $y2Obj = new Zend_Pdf_Element_Numeric($bottomRightY);
967  $x3Obj = new Zend_Pdf_Element_Numeric($bottomRightX - $radius[2]);
968  $y3Obj = new Zend_Pdf_Element_Numeric($bottomRightY);
969  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '
970  . $x2Obj->toString() . ' ' . $y2Obj->toString() . ' '
971  . $x3Obj->toString() . ' ' . $y3Obj->toString() . ' '
972  . " c\n";
973  }
974 
975  //draw bottom side
976  $x1Obj = new Zend_Pdf_Element_Numeric($bottomLeftX + $radius[3]);
977  $y1Obj = new Zend_Pdf_Element_Numeric($bottomLeftY);
978  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " l\n";
979 
980  //draw bottom left corner if needed
981  if ($radius[3] != 0) {
982  $x1Obj = new Zend_Pdf_Element_Numeric($bottomLeftX);
983  $y1Obj = new Zend_Pdf_Element_Numeric($bottomLeftY);
984  $x2Obj = new Zend_Pdf_Element_Numeric($bottomLeftX);
985  $y2Obj = new Zend_Pdf_Element_Numeric($bottomLeftY);
986  $x3Obj = new Zend_Pdf_Element_Numeric($bottomLeftX);
987  $y3Obj = new Zend_Pdf_Element_Numeric($bottomLeftY + $radius[3]);
988  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '
989  . $x2Obj->toString() . ' ' . $y2Obj->toString() . ' '
990  . $x3Obj->toString() . ' ' . $y3Obj->toString() . ' '
991  . " c\n";
992  }
993 
994  //draw left side
995  $x1Obj = new Zend_Pdf_Element_Numeric($topLeftX);
996  $y1Obj = new Zend_Pdf_Element_Numeric($topLeftY - $radius[0]);
997  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " l\n";
998 
999  //draw top left corner if needed
1000  if ($radius[0] != 0) {
1001  $x1Obj = new Zend_Pdf_Element_Numeric($topLeftX);
1002  $y1Obj = new Zend_Pdf_Element_Numeric($topLeftY);
1003  $x2Obj = new Zend_Pdf_Element_Numeric($topLeftX);
1004  $y2Obj = new Zend_Pdf_Element_Numeric($topLeftY);
1005  $x3Obj = new Zend_Pdf_Element_Numeric($topLeftX + $radius[0]);
1006  $y3Obj = new Zend_Pdf_Element_Numeric($topLeftY);
1007  $this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '
1008  . $x2Obj->toString() . ' ' . $y2Obj->toString() . ' '
1009  . $x3Obj->toString() . ' ' . $y3Obj->toString() . ' '
1010  . " c\n";
1011  }
1012 
1013  switch ($fillType) {
1015  $this->_contents .= " B*\n";
1016  break;
1018  $this->_contents .= " f*\n";
1019  break;
1021  $this->_contents .= " S\n";
1022  break;
1023  }
1024 
1025  return $this;
1026  }
1027 
1039  public function drawText($text, $x, $y, $charEncoding = '')
1040  {
1041  if ($this->_font === null) {
1042  #require_once 'Zend/Pdf/Exception.php';
1043  throw new Zend_Pdf_Exception('Font has not been set');
1044  }
1045 
1046  $this->_addProcSet('Text');
1047 
1048  $textObj = new Zend_Pdf_Element_String($this->_font->encodeString($text, $charEncoding));
1049  $xObj = new Zend_Pdf_Element_Numeric($x);
1050  $yObj = new Zend_Pdf_Element_Numeric($y);
1051 
1052  $this->_contents .= "BT\n"
1053  . $xObj->toString() . ' ' . $yObj->toString() . " Td\n"
1054  . $textObj->toString() . " Tj\n"
1055  . "ET\n";
1056 
1057  return $this;
1058  }
1059 
1068  public function pathClose()
1069  {
1071  return $this;
1072  }
1073 
1083  public function pathLine($x, $y)
1084  {
1086  return $this;
1087  }
1088 
1099  public function pathMove($x, $y)
1100  {
1102  return $this;
1103  }
1104 
1113  public function rotate($x, $y, $angle)
1114  {
1115  $cos = new Zend_Pdf_Element_Numeric(cos($angle));
1116  $sin = new Zend_Pdf_Element_Numeric(sin($angle));
1117  $mSin = new Zend_Pdf_Element_Numeric(-$sin->value);
1118 
1119  $xObj = new Zend_Pdf_Element_Numeric($x);
1120  $yObj = new Zend_Pdf_Element_Numeric($y);
1121 
1122  $mXObj = new Zend_Pdf_Element_Numeric(-$x);
1123  $mYObj = new Zend_Pdf_Element_Numeric(-$y);
1124 
1125 
1126  $this->_addProcSet('PDF');
1127  $this->_contents .= '1 0 0 1 ' . $xObj->toString() . ' ' . $yObj->toString() . " cm\n"
1128  . $cos->toString() . ' ' . $sin->toString() . ' ' . $mSin->toString() . ' ' . $cos->toString() . " 0 0 cm\n"
1129  . '1 0 0 1 ' . $mXObj->toString() . ' ' . $mYObj->toString() . " cm\n";
1130 
1131  return $this;
1132  }
1133 
1141  public function scale($xScale, $yScale)
1142  {
1143  $xScaleObj = new Zend_Pdf_Element_Numeric($xScale);
1144  $yScaleObj = new Zend_Pdf_Element_Numeric($yScale);
1145 
1146  $this->_addProcSet('PDF');
1147  $this->_contents .= $xScaleObj->toString() . ' 0 0 ' . $yScaleObj->toString() . " 0 0 cm\n";
1148 
1149  return $this;
1150  }
1151 
1159  public function translate($xShift, $yShift)
1160  {
1161  $xShiftObj = new Zend_Pdf_Element_Numeric($xShift);
1162  $yShiftObj = new Zend_Pdf_Element_Numeric($yShift);
1163 
1164  $this->_addProcSet('PDF');
1165  $this->_contents .= '1 0 0 1 ' . $xShiftObj->toString() . ' ' . $yShiftObj->toString() . " cm\n";
1166 
1167  return $this;
1168  }
1169 
1179  public function skew($x, $y, $xAngle, $yAngle)
1180  {
1181  $tanXObj = new Zend_Pdf_Element_Numeric(tan($xAngle));
1182  $tanYObj = new Zend_Pdf_Element_Numeric(-tan($yAngle));
1183 
1184  $xObj = new Zend_Pdf_Element_Numeric($x);
1185  $yObj = new Zend_Pdf_Element_Numeric($y);
1186 
1187  $mXObj = new Zend_Pdf_Element_Numeric(-$x);
1188  $mYObj = new Zend_Pdf_Element_Numeric(-$y);
1189 
1190  $this->_addProcSet('PDF');
1191  $this->_contents .= '1 0 0 1 ' . $xObj->toString() . ' ' . $yObj->toString() . " cm\n"
1192  . '1 ' . $tanXObj->toString() . ' ' . $tanYObj->toString() . " 1 0 0 cm\n"
1193  . '1 0 0 1 ' . $mXObj->toString() . ' ' . $mYObj->toString() . " cm\n";
1194 
1195  return $this;
1196  }
1197 
1208  public function rawWrite($data, $procSet = null)
1209  {
1210  if (! empty($procSet)) {
1211  $this->_addProcSet($procSet);
1212  }
1213  $this->_contents .= $data;
1214 
1215  return $this;
1216  }
1217 }
const FILL_METHOD_NON_ZERO_WINDING
Definition: Page.php:95
const LINE_DASHING_SOLID
Definition: Page.php:108
drawEllipse($x1, $y1, $x2, $y2, $param5=null, $param6=null, $param7=null)
Definition: Abstract.php:606
_addProcSet($procSetName)
setLineColor(Zend_Pdf_Color $color)
Definition: Abstract.php:184
$pattern
Definition: website.php:22
$id
Definition: fieldset.phtml:14
rawWrite($data, $procSet=null)
Definition: Abstract.php:1208
$count
Definition: recent.phtml:13
translate($xShift, $yShift)
Definition: Abstract.php:1159
setAlpha($alpha, $mode='Normal')
Definition: Abstract.php:364
setStyle(Zend_Pdf_Style $style)
Definition: Abstract.php:270
drawText($text, $x, $y, $charEncoding='')
Definition: Abstract.php:1039
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43
$resource
Definition: bulk.php:12
drawCanvas(Zend_Pdf_Canvas_Interface $canvas, $x1, $y1, $x2=null, $y2=null)
Definition: Abstract.php:120
skew($x, $y, $xAngle, $yAngle)
Definition: Abstract.php:1179
$type
Definition: item.phtml:13
drawLine($x1, $y1, $x2, $y2)
Definition: Abstract.php:772
drawPolygon($x, $y, $fillType=Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, $fillMethod=Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING)
Definition: Abstract.php:801
_attachResource($type, Zend_Pdf_Resource $resource)
drawRectangle($x1, $y1, $x2, $y2, $fillType=Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE)
Definition: Abstract.php:862
clipPolygon($x, $y, $fillMethod=Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING)
Definition: Abstract.php:498
rotate($x, $y, $angle)
Definition: Abstract.php:1113
drawLayoutBox($box, $x, $y)
Definition: Abstract.php:757
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
setFillColor(Zend_Pdf_Color $color)
Definition: Abstract.php:170
const SHAPE_DRAW_STROKE
Definition: Page.php:77
drawRoundedRectangle($x1, $y1, $x2, $y2, $radius, $fillType=Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE)
Definition: Abstract.php:909
const SHAPE_DRAW_FILL
Definition: Page.php:82
toString($factory=null)
Definition: String.php:71
setLineDashingPattern($pattern, $phase=0)
Definition: Abstract.php:218
clipEllipse($x1, $y1, $x2, $y2, $startAngle=null, $endAngle=null)
Definition: Abstract.php:416
const SHAPE_DRAW_FILL_AND_STROKE
Definition: Page.php:87
setFont(Zend_Pdf_Resource_Font $font, $fontSize)
Definition: Abstract.php:249
instructions($stroking)
clipRectangle($x1, $y1, $x2, $y2)
Definition: Abstract.php:536
clipCircle($x, $y, $radius, $startAngle=null, $endAngle=null)
Definition: Abstract.php:390
scale($xScale, $yScale)
Definition: Abstract.php:1141
$i
Definition: gallery.phtml:31
drawImage(Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2)
Definition: Abstract.php:726
drawCircle($x, $y, $radius, $param4=null, $param5=null, $param6=null)
Definition: Abstract.php:577