1 | <?php |
||
9 | abstract class BasePdf |
||
10 | { |
||
11 | /** |
||
12 | * @var Fpdi |
||
13 | */ |
||
14 | protected $pdf; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $content; |
||
20 | |||
21 | /** |
||
22 | * BasePdf constructor. |
||
23 | */ |
||
24 | public function __construct() |
||
30 | |||
31 | /** |
||
32 | * Check for url given path. |
||
33 | * |
||
34 | * @param $url |
||
35 | * @return bool |
||
36 | */ |
||
37 | protected function validUrl($url) |
||
45 | |||
46 | /** |
||
47 | * Check file type from string content is pdf. |
||
48 | * |
||
49 | * @param $content |
||
50 | * @return string |
||
51 | */ |
||
52 | protected function mimeType($content) |
||
64 | |||
65 | /** |
||
66 | * Set file content. |
||
67 | * |
||
68 | * @param $pdf |
||
69 | * |
||
70 | * @throws UnableToOpen |
||
71 | */ |
||
72 | protected function setFileContent($pdf) |
||
84 | |||
85 | /** |
||
86 | * Render pdf content. |
||
87 | * |
||
88 | * @return mixed |
||
89 | */ |
||
90 | abstract public function render(); |
||
91 | |||
92 | /** |
||
93 | * Save to a local server file with the name given by name. |
||
94 | * |
||
95 | * @param string $filename |
||
96 | * @return string |
||
97 | */ |
||
98 | public function save(string $filename) |
||
104 | |||
105 | /** |
||
106 | * Send the Pdf inline to the browser. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | public function stream() |
||
116 | |||
117 | /** |
||
118 | * Return the pdf as a string. |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function content() |
||
128 | } |
||
129 |