1 | <?php |
||
18 | class EpsWriter extends AbstractWriter |
||
19 | { |
||
20 | /** |
||
21 | * EpsWriter constructor. |
||
22 | */ |
||
23 | public function __construct() |
||
24 | { |
||
25 | parent::__construct(new Eps()); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @inheritdoc |
||
30 | */ |
||
31 | public function writeString(QrCodeInterface $qrCode) |
||
32 | { |
||
33 | /** @var Eps $renderer */ |
||
34 | $renderer = $this->renderer; |
||
35 | $renderer->setWidth($qrCode->getSize()); |
||
36 | $renderer->setHeight($qrCode->getSize()); |
||
37 | $renderer->setMargin(0); |
||
38 | $renderer->setForegroundColor($this->convertColor($qrCode->getForegroundColor())); |
||
39 | $renderer->setBackgroundColor($this->convertColor($qrCode->getBackgroundColor())); |
||
40 | $writer = new Writer($renderer); |
||
41 | $string = $writer->writeString( |
||
42 | $qrCode->getText(), |
||
43 | $qrCode->getEncoding(), |
||
44 | $this->convertErrorCorrectionLevel($qrCode->getErrorCorrectionLevel()) |
||
45 | ); |
||
46 | $string = $this->addMargin($string, $qrCode); |
||
47 | |||
48 | return $string; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | */ |
||
54 | public function getContentType() |
||
58 | |||
59 | /** |
||
60 | * @param string $string |
||
61 | * @param QrCodeInterface $qrCode |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | protected function addMargin($string, QrCodeInterface $qrCode) |
||
103 | } |
||
104 |