source: trunk/client/inc/hpdf5/spipu/html2pdf/src/Tag/Svg/Polygon.php@ 347

Last change on this file since 347 was 347, checked in by roby, 3 years ago

Aggiornamento per compatibilità con php7.4

File size: 1.7 KB
Line 
1<?php
2/**
3 * Html2Pdf Library - Tag class
4 *
5 * HTML => PDF converter
6 * distributed under the OSL-3.0 License
7 *
8 * @package Html2pdf
9 * @author Laurent MINGUET <webmaster@html2pdf.fr>
10 * @copyright 2017 Laurent MINGUET
11 */
12namespace Spipu\Html2Pdf\Tag\Svg;
13
14use Spipu\Html2Pdf\Tag\AbstractSvgTag;
15
16/**
17 * Tag Polygon
18 */
19class Polygon extends AbstractSvgTag
20{
21 /**
22 * @inheritdoc
23 */
24 public function getName()
25 {
26 return 'polygon';
27 }
28
29 /**
30 * @inheritdoc
31 */
32 protected function drawSvg($properties)
33 {
34 $styles = $this->parsingCss->getSvgStyle($this->getName(), $properties);
35 $style = $this->pdf->svgSetStyle($styles);
36
37 $path = (isset($properties['points']) ? $properties['points'] : null);
38 if ($path) {
39 $path = str_replace(',', ' ', $path);
40 $path = preg_replace('/[\s]+/', ' ', trim($path));
41
42 // prepare the path
43 $path = explode(' ', $path);
44 foreach ($path as $k => $v) {
45 $path[$k] = trim($v);
46 if ($path[$k] === '') {
47 unset($path[$k]);
48 }
49 }
50 $path = array_values($path);
51
52 $amountPath = count($path);
53 $actions = array();
54 for ($k=0; $k<$amountPath; $k+=2) {
55 $actions[] = array(
56 ($k ? 'L' : 'M') ,
57 $this->cssConverter->convertToMM($path[$k+0], $this->svgDrawer->getProperty('w')),
58 $this->cssConverter->convertToMM($path[$k+1], $this->svgDrawer->getProperty('h'))
59 );
60 }
61 $actions[] = array('z');
62
63 // drawing
64 $this->pdf->svgPolygone($actions, $style);
65 }
66 }
67}
Note: See TracBrowser for help on using the repository browser.