1 | <?php |
||
11 | class TcpdfWrapper |
||
12 | { |
||
13 | private $__pdf; |
||
14 | private $__fonts = []; |
||
15 | private $__tcpdfFonts; |
||
16 | // 読み込みフォントファイルのパス |
||
17 | private $fontFilePath; |
||
18 | // フォントの設定キャッシュファイル出力先ディレクトリ |
||
19 | private $fontSettingCacheFileOutDir = ''; |
||
20 | |||
21 | const TATEGAKI_TYPE_NORMAL = 1; |
||
22 | const TATEGAKI_TYPE_ROUND = 2; |
||
23 | const TATEGAKI_TYPE_RIGHT = 3; |
||
24 | |||
25 | // publicにしておくので必要に応じて設定 |
||
26 | public $setTategakiType = [ |
||
27 | self::TATEGAKI_TYPE_ROUND => [ |
||
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 | '〙', |
||
72 | ], |
||
73 | self::TATEGAKI_TYPE_RIGHT => [ |
||
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 | ], |
||
106 | ]; |
||
107 | |||
108 | /** |
||
109 | * __construct |
||
110 | * |
||
111 | * @author hagiwara |
||
112 | */ |
||
113 | public function __construct() |
||
118 | |||
119 | /** |
||
120 | * setfontSettingCacheFileOutDir |
||
121 | * |
||
122 | * @param string $fontSettingCacheFileOutDir |
||
123 | * @return void |
||
124 | * @author kawano |
||
125 | */ |
||
126 | public function setFontSettingCacheFileOutDir($fontSettingCacheFileOutDir) |
||
130 | |||
131 | /** |
||
132 | * setPrintHeader |
||
133 | * |
||
134 | * @param boolean $print 出力フラグ |
||
135 | * @author hagiwara |
||
136 | */ |
||
137 | public function setPrintHeader($print) |
||
141 | |||
142 | /** |
||
143 | * setPrintFooter |
||
144 | * |
||
145 | * @param boolean $print 出力フラグ |
||
146 | * @author hagiwara |
||
147 | */ |
||
148 | public function setPrintFooter($print) |
||
152 | |||
153 | /** |
||
154 | * setFontFilePath |
||
155 | * setFont($name, $path)で指定された$pathをプロパティにセット |
||
156 | * |
||
157 | * @param string $fontFilePath 読み込みフォントファイルのパス |
||
158 | * @return void |
||
159 | */ |
||
160 | private function setFontFilePath($fontFilePath) |
||
164 | |||
165 | /** |
||
166 | * setFont |
||
167 | * |
||
168 | * @param string $name フォント名 |
||
169 | * @param string $path フォントパス nullでデフォルトセット |
||
170 | * @author hagiwara |
||
171 | */ |
||
172 | public function setFont($name, $path) |
||
178 | |||
179 | /** |
||
180 | * addPage |
||
181 | * |
||
182 | * @param string $template テンプレートパス |
||
183 | * @param integer $templateIndex テンプレートページ |
||
184 | * @author hagiwara |
||
185 | */ |
||
186 | public function addPage($template, $templateIndex) |
||
200 | |||
201 | /** |
||
202 | * setVal |
||
203 | * |
||
204 | * @param string $text テキスト |
||
205 | * @param array $option オプション |
||
206 | * @param array $rotateOption 回転オプション(縦書き対応用) |
||
207 | * @author hagiwara |
||
208 | */ |
||
209 | public function setVal($text, $option, $rotateOption = []) |
||
261 | |||
262 | /** |
||
263 | * setValTategaki |
||
264 | * 縦書き対応/改行は対応しきれない。折り返しもしない |
||
265 | * |
||
266 | * @param string $text テキスト |
||
267 | * @param array $option オプション |
||
268 | * @author hagiwara |
||
269 | */ |
||
270 | public function setValTategaki($text, $option) |
||
327 | |||
328 | /** |
||
329 | * getTategakiWordType |
||
330 | * 縦書きに必要な種別の取得 |
||
331 | * |
||
332 | * @param string $word テキスト |
||
333 | * @return int |
||
334 | * @author hagiwara |
||
335 | */ |
||
336 | private function getTategakiWordType($word) |
||
346 | |||
347 | /** |
||
348 | * setHtml |
||
349 | * |
||
350 | * @param string $html HTML |
||
351 | * @param array $option オプション |
||
352 | * @author hagiwara |
||
353 | */ |
||
354 | public function setHtml($html, $option) |
||
383 | |||
384 | /** |
||
385 | * getFont |
||
386 | * |
||
387 | * @param string $font フォント名 |
||
388 | * @author hagiwara |
||
389 | */ |
||
390 | private function getFont($font) |
||
398 | |||
399 | /** |
||
400 | * setImage |
||
401 | * |
||
402 | * @param string $image 画像パス |
||
403 | * @param array $option オプション |
||
404 | * @author hagiwara |
||
405 | */ |
||
406 | public function setImage($image, $option) |
||
420 | |||
421 | |||
422 | /** |
||
423 | * colorCodeConvert |
||
424 | * |
||
425 | * @param string $color カラーコード(16進数) |
||
426 | * @author hagiwara |
||
427 | */ |
||
428 | private function colorCodeConvert($color) |
||
446 | |||
447 | /** |
||
448 | * setAutoPageBreak |
||
449 | * page brackeを自動で行うかどうか。画像を下部に埋め込む際には切っておいたほうが良さげ |
||
450 | * @param int $auto |
||
451 | * @param int $margin |
||
452 | */ |
||
453 | public function setAutoPageBreak($auto, $margin = 0) |
||
457 | |||
458 | /** |
||
459 | * getStringWidth |
||
460 | * |
||
461 | * @param string $text テキスト |
||
462 | * @param string $font フォント名 |
||
463 | * @param string $fontstyle フォントスタイル |
||
464 | * @param integer $fontsize サイズ |
||
465 | * @param bool $getarray 結果を1文字ずつ配列で返すか |
||
466 | * @author hagiwara |
||
467 | */ |
||
468 | public function getStringWidth($text, $font, $fontstyle, $fontsize, $getarray = false) { |
||
471 | |||
472 | /** |
||
473 | * write |
||
474 | * |
||
475 | * @param string $file 出力ファイル |
||
476 | * @author hagiwara |
||
477 | */ |
||
478 | public function write($file) |
||
486 | |||
487 | /** |
||
488 | * フォント設定キャッシュファイルのパスを返す |
||
489 | * $this->fontSettingCacheFileOutDir (上記ファイルの出力先ディレクトリ) を指定した場合のみ呼ばれる |
||
490 | * [関数中のアルゴリズムで生成されたフォント名].php が作られているので、そのpathを返す |
||
491 | * @param string $font フォント名 |
||
492 | * @return string |
||
493 | * @author kawano |
||
494 | */ |
||
495 | private function generateFontSettingCacheFilePath($font) |
||
522 | } |
||
523 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.