回答編集履歴
2
数値を修正しました。
answer
CHANGED
@@ -43,8 +43,8 @@
|
|
43
43
|
$pdf->useTemplate($template, 0, 0);
|
44
44
|
|
45
45
|
$pdf->Cell(10, CELL_HEIGHT, $row[1], 0, 0, 'C', "", 2, false, 'C', '');
|
46
|
-
$pdf->Cell(
|
46
|
+
$pdf->Cell(20, CELL_HEIGHT, $row[2], 0, 0, 'C', "", 2, false, 'C', '');
|
47
|
-
$pdf->Cell(
|
47
|
+
$pdf->Cell(30, CELL_HEIGHT, $row[3], 0, 0, 'C', "", 2, false, 'C', '');
|
48
48
|
|
49
49
|
$y += 10;
|
50
50
|
}
|
1
最終的なコードを変更しました。
answer
CHANGED
@@ -1,22 +1,59 @@
|
|
1
1
|
```php
|
2
|
+
$data = array(
|
3
|
+
array("1", "testest", "TESTTEST", "TEST", "TT", "00000", "1", "000000", "0000", "0000", "0000", "0000", "00000", "test" ),
|
4
|
+
array("2", "testest", "TESTTEST", "TEST", "TT", "00000", "1", "000000", "0000", "0000", "0000", "0000", "00000", "test" ),
|
5
|
+
array("3", "testest", "TESTTEST", "TEST", "TT", "00000", "1", "000000", "0000", "0000", "0000", "0000", "00000", "test" ),
|
6
|
+
);
|
7
|
+
|
8
|
+
include(dirname(__FILE__).'/tcpdf/tcpdf.php');
|
9
|
+
include(dirname(__FILE__).'/fpdi/fpdi.php');
|
10
|
+
|
11
|
+
// PDF関連の設定
|
12
|
+
define('ORIENTATION', 'L'); //横向き
|
13
|
+
define('FORMAT', 'A4');
|
14
|
+
|
15
|
+
define('TEMPLATE_FILE', 'test.pdf');
|
16
|
+
|
17
|
+
// 書き込み位置の設定(単位:ミリメートル)
|
18
|
+
define('CELL_TOP', 80);
|
19
|
+
define('CELL_LEFT', 5);
|
20
|
+
define('CELL_HEIGHT', 10);
|
21
|
+
|
22
|
+
$pdf = new FPDI();
|
23
|
+
|
24
|
+
// PDF 設定
|
25
|
+
$pdf->SetMargins(0, 0, 0);
|
26
|
+
$pdf->SetAutoPageBreak(true,15);
|
27
|
+
$pdf->SetCellPadding(0);
|
28
|
+
$pdf->setPrintHeader(false);
|
29
|
+
$pdf->setPrintFooter(false);
|
30
|
+
$pdf->SetFont('kozgopromedium', '', 10);
|
31
|
+
$pdf->AddPage(ORIENTATION, FORMAT);
|
32
|
+
|
33
|
+
// テンプレート関連処理
|
34
|
+
$pdf->setSourceFile(TEMPLATE_FILE);
|
35
|
+
$template = $pdf->importPage(1);
|
36
|
+
$pdf->useTemplate($template, 0, 0);
|
37
|
+
|
2
38
|
//データを書き込む
|
3
39
|
$y = CELL_TOP;
|
40
|
+
foreach($data as $i => $row){
|
4
41
|
|
5
|
-
foreach($items as $i => $row){
|
6
|
-
|
7
42
|
$pdf->SetXY(CELL_LEFT, $y);
|
8
|
-
$pdf->Cell(10,10, $row[0], 1, 0, 'C', "", 2, false, 'C', '');
|
9
|
-
・
|
10
|
-
・
|
11
|
-
・
|
12
|
-
(配列分続く)
|
13
|
-
$y += 10;
|
14
43
|
$pdf->useTemplate($template, 0, 0);
|
15
44
|
|
45
|
+
$pdf->Cell(10, CELL_HEIGHT, $row[1], 0, 0, 'C', "", 2, false, 'C', '');
|
46
|
+
$pdf->Cell(14, CELL_HEIGHT, $row[2], 0, 0, 'C', "", 2, false, 'C', '');
|
47
|
+
$pdf->Cell(12, CELL_HEIGHT, $row[3], 0, 0, 'C', "", 2, false, 'C', '');
|
48
|
+
|
49
|
+
$y += 10;
|
16
50
|
}
|
17
51
|
|
52
|
+
$pdf->Output('test.pdf', 'D');
|
18
53
|
|
19
54
|
```
|
20
55
|
と、
|
21
56
|
Cellの大きさが一つ一つ違うので個別にCellを書いたところ解決できました。
|
22
|
-
ありがとうございました。
|
57
|
+
ありがとうございました。
|
58
|
+
|
59
|
+
追記:最終的なコードを修正しました。
|