- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormWriter.php
More file actions
63 lines (46 loc) · 1.39 KB
/
FormWriter.php
File metadata and controls
63 lines (46 loc) · 1.39 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
<?php
namespace Mpdf\Writer;
use Mpdf\Strict;
use Mpdf\Mpdf;
final class FormWriter
{
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 writeFormObjects() // _putformobjects
{
foreach ($this->mpdf->formobjects as $file => $info) {
$this->writer->object();
$this->mpdf->formobjects[$file]['n'] = $this->mpdf->n;
$this->writer->write('<</Type /XObject');
$this->writer->write('/Subtype /Form');
$this->writer->write('/Group ' . ($this->mpdf->n + 1) . ' 0 R');
$this->writer->write('/BBox [' . $info['x'] . ' ' . $info['y'] . ' ' . ($info['w'] + $info['x']) . ' ' . ($info['h'] + $info['y']) . ']');
if ($this->mpdf->compress) {
$this->writer->write('/Filter /FlateDecode');
}
$data = $this->mpdf->compress ? gzcompress($info['data']) : $info['data'];
$this->writer->write('/Length ' . strlen($data) . '>>');
$this->writer->stream($data);
unset($this->mpdf->formobjects[$file]['data']);
$this->writer->write('endobj');
// Required for SVG transparency (opacity) to work
$this->writer->object();
$this->writer->write('<</Type /Group');
$this->writer->write('/S /Transparency');
$this->writer->write('>>');
$this->writer->write('endobj');
}
}
}