- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionalContentWriter.php
More file actions
71 lines (55 loc) · 1.84 KB
/
OptionalContentWriter.php
File metadata and controls
71 lines (55 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Mpdf\Writer;
use Mpdf\Strict;
use Mpdf\Mpdf;
final class OptionalContentWriter
{
use Strict;
/**
* @var \Mpdf\Mpdf
*/
private $mpdf;
/**
* @var \Mpdf\Writer\BaseWriter
*/
private $writer;
public function __construct(Mpdf $mpdf, BaseWriter $writer)
{
$this->mpdf = $mpdf;
$this->writer = $writer;
}
public function writeOptionalContentGroups() // _putocg Optional Content Groups
{
if ($this->mpdf->hasOC) {
$this->writer->object();
$this->mpdf->n_ocg_print = $this->mpdf->n;
$this->writer->write('<</Type /OCG /Name ' . $this->writer->string('Print only'));
$this->writer->write('/Usage <</Print <</PrintState /ON>> /View <</ViewState /OFF>>>>>>');
$this->writer->write('endobj');
$this->writer->object();
$this->mpdf->n_ocg_view = $this->mpdf->n;
$this->writer->write('<</Type /OCG /Name ' . $this->writer->string('Screen only'));
$this->writer->write('/Usage <</Print <</PrintState /OFF>> /View <</ViewState /ON>>>>>>');
$this->writer->write('endobj');
$this->writer->object();
$this->mpdf->n_ocg_hidden = $this->mpdf->n;
$this->writer->write('<</Type /OCG /Name ' . $this->writer->string('Hidden'));
$this->writer->write('/Usage <</Print <</PrintState /OFF>> /View <</ViewState /OFF>>>>>>');
$this->writer->write('endobj');
}
if (count($this->mpdf->layers)) {
ksort($this->mpdf->layers);
foreach ($this->mpdf->layers as $id => $layer) {
$this->writer->object();
$this->mpdf->layers[$id]['n'] = $this->mpdf->n;
if (isset($this->mpdf->layerDetails[$id]['name']) && $this->mpdf->layerDetails[$id]['name']) {
$name = $this->mpdf->layerDetails[$id]['name'];
} else {
$name = $layer['name'];
}
$this->writer->write('<</Type /OCG /Name ' . $this->writer->utf16BigEndianTextString($name) . '>>');
$this->writer->write('endobj');
}
}
}
}