1<?php
2
3namespace Mpdf\Writer;
4
5use Mpdf\Strict;
6use Mpdf\Mpdf;
7
8final class ColorWriter
9{
10
11	use Strict;
12
13	/**
14	 * @var \Mpdf\Mpdf
15	 */
16	private $mpdf;
17
18	/**
19	 * @var \Mpdf\Writer\BaseWriter
20	 */
21	private $writer;
22
23	public function __construct(Mpdf $mpdf, BaseWriter $writer)
24	{
25		$this->mpdf = $mpdf;
26		$this->writer = $writer;
27	}
28
29	public function writeSpotColors() // _putspotcolors
30	{
31		foreach ($this->mpdf->spotColors as $name => $color) {
32
33			$this->writer->object();
34
35			$this->writer->write('[/Separation /' . str_replace(' ', '#20', $name));
36			$this->writer->write('/DeviceCMYK <<');
37			$this->writer->write('/Range [0 1 0 1 0 1 0 1] /C0 [0 0 0 0] ');
38			$this->writer->write(sprintf('/C1 [%.3F %.3F %.3F %.3F] ', $color['c'] / 100, $color['m'] / 100, $color['y'] / 100, $color['k'] / 100));
39			$this->writer->write('/FunctionType 2 /Domain [0 1] /N 1>>]');
40			$this->writer->write('endobj');
41
42			$this->mpdf->spotColors[$name]['n'] = $this->mpdf->n;
43		}
44	}
45
46}
47