1 | <?php |
||
11 | class TcpdfWrapper |
||
12 | { |
||
13 | private $__pdf; |
||
14 | private $__fonts = []; |
||
15 | private $__tcpdfFonts; |
||
16 | // fontの設定キャッシュファイル出力先ディレクトリ |
||
17 | private $fontSettingCacheFileOutDir = ''; |
||
18 | |||
19 | const TATEGAKI_TYPE_NORMAL = 1; |
||
20 | const TATEGAKI_TYPE_ROUND = 2; |
||
21 | const TATEGAKI_TYPE_RIGHT = 3; |
||
22 | |||
23 | // publicにしておくので必要に応じて設定 |
||
24 | public $setTategakiType = [ |
||
25 | self::TATEGAKI_TYPE_ROUND => [ |
||
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 | '〙', |
||
70 | ], |
||
71 | self::TATEGAKI_TYPE_RIGHT => [ |
||
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 | |||
106 | /** |
||
107 | * __construct |
||
108 | * |
||
109 | * @author hagiwara |
||
110 | */ |
||
111 | public function __construct() |
||
116 | |||
117 | /** |
||
118 | * setfontSettingCacheFileOutDir |
||
119 | * |
||
120 | * @param string $fontSettingCacheFileOutDir |
||
121 | * @return void |
||
122 | * @author kawano |
||
123 | */ |
||
124 | public function setFontSettingCacheFileOutDir($fontSettingCacheFileOutDir) |
||
128 | |||
129 | /** |
||
130 | * getfontSettingCacheFileOutDir |
||
131 | * |
||
132 | * @return string |
||
133 | * @author kawano |
||
134 | */ |
||
135 | public function getFontSettingCacheFileOutDir() |
||
139 | |||
140 | /** |
||
141 | * setPrintHeader |
||
142 | * |
||
143 | * @param boolean $print 出力フラグ |
||
144 | * @author hagiwara |
||
145 | */ |
||
146 | public function setPrintHeader($print) |
||
150 | |||
151 | /** |
||
152 | * setPrintFooter |
||
153 | * |
||
154 | * @param boolean $print 出力フラグ |
||
155 | * @author hagiwara |
||
156 | */ |
||
157 | public function setPrintFooter($print) |
||
161 | |||
162 | /** |
||
163 | * setFont |
||
164 | * |
||
165 | * @param string $name フォント名 |
||
166 | * @param string $path フォントパス nullでデフォルトセット |
||
167 | * @author hagiwara |
||
168 | */ |
||
169 | public function setFont($name, $path) |
||
173 | |||
174 | /** |
||
175 | * addPage |
||
176 | * |
||
177 | * @param string $template テンプレートパス |
||
178 | * @param integer $templateIndex テンプレートページ |
||
179 | * @author hagiwara |
||
180 | */ |
||
181 | public function addPage($template, $templateIndex) |
||
195 | |||
196 | /** |
||
197 | * setVal |
||
198 | * |
||
199 | * @param string $text テキスト |
||
200 | * @param array $option オプション |
||
201 | * @param array $rotateOption 回転オプション(縦書き対応用) |
||
202 | * @author hagiwara |
||
203 | */ |
||
204 | public function setVal($text, $option, $rotateOption = []) |
||
259 | |||
260 | /** |
||
261 | * setValTategaki |
||
262 | * 縦書き対応/改行は対応しきれない。折り返しもしない |
||
263 | * |
||
264 | * @param string $text テキスト |
||
265 | * @param array $option オプション |
||
266 | * @author hagiwara |
||
267 | */ |
||
268 | public function setValTategaki($text, $option) |
||
325 | |||
326 | /** |
||
327 | * getTategakiWordType |
||
328 | * 縦書きに必要な種別の取得 |
||
329 | * |
||
330 | * @param string $word テキスト |
||
331 | * @return int |
||
332 | * @author hagiwara |
||
333 | */ |
||
334 | private function getTategakiWordType($word) |
||
344 | |||
345 | /** |
||
346 | * setHtml |
||
347 | * |
||
348 | * @param string $html HTML |
||
349 | * @param array $option オプション |
||
350 | * @author hagiwara |
||
351 | */ |
||
352 | public function setHtml($html, $option) |
||
384 | |||
385 | /** |
||
386 | * getFont |
||
387 | * |
||
388 | * @param string $font フォント名 |
||
389 | * @author hagiwara |
||
390 | */ |
||
391 | private function getFont($font) |
||
399 | |||
400 | /** |
||
401 | * setImage |
||
402 | * |
||
403 | * @param string $image 画像パス |
||
404 | * @param array $option オプション |
||
405 | * @author hagiwara |
||
406 | */ |
||
407 | public function setImage($image, $option) |
||
421 | |||
422 | |||
423 | /** |
||
424 | * colorCodeConvert |
||
425 | * |
||
426 | * @param string $color カラーコード(16進数) |
||
427 | * @author hagiwara |
||
428 | */ |
||
429 | private function colorCodeConvert($color) |
||
447 | |||
448 | /** |
||
449 | * setAutoPageBreak |
||
450 | * page brackeを自動で行うかどうか。画像を下部に埋め込む際には切っておいたほうが良さげ |
||
451 | * @param int $auto |
||
452 | * @param int $margin |
||
453 | */ |
||
454 | public function setAutoPageBreak($auto, $margin = 0) |
||
458 | |||
459 | /** |
||
460 | * getStringWidth |
||
461 | * |
||
462 | * @param string $text テキスト |
||
463 | * @param string $font フォント名 |
||
464 | * @param string $fontstyle フォントスタイル |
||
465 | * @param integer $fontsize サイズ |
||
466 | * @param bool $getarray 結果を1文字ずつ配列で返すか |
||
467 | * @author hagiwara |
||
468 | */ |
||
469 | public function getStringWidth($text, $font, $fontstyle, $fontsize, $getarray = false) { |
||
472 | |||
473 | /** |
||
474 | * write |
||
475 | * |
||
476 | * @param string $file 出力ファイル |
||
477 | * @author hagiwara |
||
478 | */ |
||
479 | public function write($file) |
||
487 | |||
488 | /** |
||
489 | * フォント設定キャッシュファイルのパスを返す |
||
490 | * $this->fontSettingCacheFileOutDir (上記ファイルの出力先ディレクトリ) を指定した場合のみ呼ばれる |
||
491 | * ファイル名生成アルゴリズム部分は右記を参照: https://github.com/tecnickcom/TCPDF/blob/master/include/tcpdf_fonts.php#L79 〜 https://github.com/tecnickcom/TCPDF/blob/master/include/tcpdf_fonts.php#L92 |
||
492 | * @param string $font フォント名 |
||
493 | * @return string |
||
494 | * @author kawano |
||
495 | */ |
||
496 | private function generateFontSettingCacheFilePath($font) |
||
514 | } |
||
515 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.