1 | <?php |
||
11 | class TcpdfWrapper |
||
12 | { |
||
13 | private $__pdf; |
||
14 | private $__fonts = []; |
||
15 | private $__tcpdfFonts; |
||
16 | |||
17 | const TATEGAKI_TYPE_NORMAL = 1; |
||
18 | const TATEGAKI_TYPE_ROUND = 2; |
||
19 | const TATEGAKI_TYPE_RIGHT = 3; |
||
20 | |||
21 | // publicにしておくので必要に応じて設定 |
||
22 | public $setTategakiType = [ |
||
23 | self::TATEGAKI_TYPE_ROUND => [ |
||
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 | self::TATEGAKI_TYPE_RIGHT => [ |
||
70 | 'ぁ', |
||
71 | 'ぃ', |
||
72 | 'ぅ', |
||
73 | 'ぇ', |
||
74 | 'ぉ', |
||
75 | 'ゃ', |
||
76 | 'ゅ', |
||
77 | 'ょ', |
||
78 | 'っ', |
||
79 | 'ァ', |
||
80 | 'ィ', |
||
81 | 'ぅ', |
||
82 | 'ェ', |
||
83 | 'ォ', |
||
84 | 'ャ', |
||
85 | 'ュ', |
||
86 | 'ョ', |
||
87 | 'ッ', |
||
88 | 'ァ', |
||
89 | 'ィ', |
||
90 | 'ゥ', |
||
91 | 'ェ', |
||
92 | 'ォ', |
||
93 | 'ャ', |
||
94 | 'ュ', |
||
95 | 'ョ', |
||
96 | 'ッ', |
||
97 | '、', |
||
98 | '。', |
||
99 | '.', |
||
100 | ',', |
||
101 | ], |
||
102 | ]; |
||
103 | |||
104 | /** |
||
105 | * __construct |
||
106 | * |
||
107 | * @author hagiwara |
||
108 | */ |
||
109 | public function __construct() |
||
114 | |||
115 | /** |
||
116 | * setPrintHeader |
||
117 | * |
||
118 | * @param boolean $print 出力フラグ |
||
119 | * @author hagiwara |
||
120 | */ |
||
121 | public function setPrintHeader($print) |
||
125 | |||
126 | /** |
||
127 | * setPrintFooter |
||
128 | * |
||
129 | * @param boolean $print 出力フラグ |
||
130 | * @author hagiwara |
||
131 | */ |
||
132 | public function setPrintFooter($print) |
||
136 | |||
137 | /** |
||
138 | * setFont |
||
139 | * |
||
140 | * @param string $name フォント名 |
||
141 | * @param string $path フォントパス nullでデフォルトセット |
||
142 | * @author hagiwara |
||
143 | */ |
||
144 | public function setFont($name, $path) |
||
148 | |||
149 | /** |
||
150 | * addPage |
||
151 | * |
||
152 | * @param string $template テンプレートパス |
||
153 | * @param integer $templateIndex テンプレートページ |
||
154 | * @author hagiwara |
||
155 | */ |
||
156 | public function addPage($template, $templateIndex) |
||
170 | |||
171 | /** |
||
172 | * setVal |
||
173 | * |
||
174 | * @param string $text テキスト |
||
175 | * @param array $option オプション |
||
176 | * @param array $rotateOption 回転オプション(縦書き対応用) |
||
177 | * @author hagiwara |
||
178 | */ |
||
179 | public function setVal($text, $option, $rotateOption = []) |
||
230 | |||
231 | /** |
||
232 | * setValTategaki |
||
233 | * 縦書き対応/改行は対応しきれない。折り返しもしない |
||
234 | * |
||
235 | * @param string $text テキスト |
||
236 | * @param array $option オプション |
||
237 | * @author hagiwara |
||
238 | */ |
||
239 | public function setValTategaki($text, $option) |
||
296 | |||
297 | /** |
||
298 | * getTategakiWordType |
||
299 | * 縦書きに必要な種別の取得 |
||
300 | * |
||
301 | * @param string $word テキスト |
||
302 | * @return int |
||
303 | * @author hagiwara |
||
304 | */ |
||
305 | private function getTategakiWordType($word) |
||
315 | |||
316 | /** |
||
317 | * setHtml |
||
318 | * |
||
319 | * @param string $html HTML |
||
320 | * @param array $option オプション |
||
321 | * @author hagiwara |
||
322 | */ |
||
323 | public function setHtml($html, $option) |
||
351 | |||
352 | /** |
||
353 | * getFont |
||
354 | * |
||
355 | * @param string $font フォント名 |
||
356 | * @author hagiwara |
||
357 | */ |
||
358 | private function getFont($font) |
||
366 | |||
367 | /** |
||
368 | * setImage |
||
369 | * |
||
370 | * @param string $image 画像パス |
||
371 | * @param array $option オプション |
||
372 | * @author hagiwara |
||
373 | */ |
||
374 | public function setImage($image, $option) |
||
388 | |||
389 | |||
390 | /** |
||
391 | * colorCodeConvert |
||
392 | * |
||
393 | * @param string $color カラーコード(16進数) |
||
394 | * @author hagiwara |
||
395 | */ |
||
396 | private function colorCodeConvert($color) |
||
414 | |||
415 | /** |
||
416 | * setAutoPageBreak |
||
417 | * page brackeを自動で行うかどうか。画像を下部に埋め込む際には切っておいたほうが良さげ |
||
418 | * @param int $auto |
||
419 | * @param int $margin |
||
420 | */ |
||
421 | public function setAutoPageBreak($auto, $margin = 0) |
||
425 | |||
426 | /** |
||
427 | * getStringWidth |
||
428 | * |
||
429 | * @param string $text テキスト |
||
430 | * @param string $font フォント名 |
||
431 | * @param string $fontstyle フォントスタイル |
||
432 | * @param integer $fontsize サイズ |
||
433 | * @param bool $getarray 結果を1文字ずつ配列で返すか |
||
434 | * @author hagiwara |
||
435 | */ |
||
436 | public function getStringWidth($text, $font, $fontstyle, $fontsize, $getarray = false) { |
||
439 | |||
440 | /** |
||
441 | * write |
||
442 | * |
||
443 | * @param string $file 出力ファイル |
||
444 | * @author hagiwara |
||
445 | */ |
||
446 | public function write($file) |
||
454 | |||
455 | } |
||
456 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.