|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* BaconPdf |
|
4
|
|
|
* |
|
5
|
|
|
* @link http://github.com/Bacon/BaconPdf For the canonical source repository |
|
6
|
|
|
* @copyright 2015 Ben Scholzen (DASPRiD) |
|
7
|
|
|
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Bacon\Pdf; |
|
11
|
|
|
|
|
12
|
|
|
use Bacon\Pdf\Writer\PageWriter; |
|
13
|
|
|
|
|
14
|
|
|
final class Page |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var PageWriter |
|
18
|
|
|
*/ |
|
19
|
|
|
private $pageWriter; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param PageWriter $pageWriter |
|
23
|
|
|
* @param float $width |
|
24
|
|
|
* @param float $height |
|
25
|
|
|
*/ |
|
26
|
|
|
public function __construct(PageWriter $pageWriter, $width, $height) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->pageWriter = $pageWriter; |
|
29
|
|
|
$this->pageWriter->setBox('MediaBox', new Rectangle(0, 0, $width, $height)); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Sets the crop box to which the page should be cropped to for displaying or printing. |
|
34
|
|
|
* |
|
35
|
|
|
* @param Rectangle $cropBox |
|
36
|
|
|
*/ |
|
37
|
|
|
public function setCropBox(Rectangle $cropBox) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->pageWriter->setBox('CropBox', $cropBox); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Sets the bleed box to which the page should be clipped in a production environment. |
|
44
|
|
|
* |
|
45
|
|
|
* @param Rectangle $bleedBox |
|
46
|
|
|
*/ |
|
47
|
|
|
public function setBleedBox(Rectangle $bleedBox) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->pageWriter->setBox('BleedBox', $bleedBox); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Sets the trim box to which the finished page should be trimmed. |
|
54
|
|
|
* |
|
55
|
|
|
* @param Rectangle $trimBox |
|
56
|
|
|
*/ |
|
57
|
|
|
public function setTrimBox(Rectangle $trimBox) |
|
58
|
|
|
{ |
|
59
|
|
|
$this->pageWriter->setBox('TrimBox', $trimBox); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Sets the art box which contains the meaningful content of the page. |
|
64
|
|
|
* |
|
65
|
|
|
* @param Rectangle $artBox |
|
66
|
|
|
*/ |
|
67
|
|
|
public function setArtBox(Rectangle $artBox) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->pageWriter->setBox('ArtBox', $artBox); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Rotates the page for output. |
|
74
|
|
|
* |
|
75
|
|
|
* The supplied value must be a multiple of 90, so either 0, 90, 180 oder 270. |
|
76
|
|
|
* |
|
77
|
|
|
* @param int $degrees |
|
78
|
|
|
*/ |
|
79
|
|
|
public function rotate($degrees) |
|
80
|
|
|
{ |
|
81
|
|
|
$this->pageWriter->setRotation($degrees); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|