回答編集履歴

2

数値を修正しました。

2019/10/08 06:15

投稿

free_gin
free_gin

スコア8

test CHANGED
@@ -88,9 +88,9 @@
88
88
 
89
89
  $pdf->Cell(10, CELL_HEIGHT, $row[1], 0, 0, 'C', "", 2, false, 'C', '');
90
90
 
91
- $pdf->Cell(14, CELL_HEIGHT, $row[2], 0, 0, 'C', "", 2, false, 'C', '');
91
+ $pdf->Cell(20, CELL_HEIGHT, $row[2], 0, 0, 'C', "", 2, false, 'C', '');
92
92
 
93
- $pdf->Cell(12, CELL_HEIGHT, $row[3], 0, 0, 'C', "", 2, false, 'C', '');
93
+ $pdf->Cell(30, CELL_HEIGHT, $row[3], 0, 0, 'C', "", 2, false, 'C', '');
94
94
 
95
95
 
96
96
 

1

最終的なコードを変更しました。

2019/10/08 06:15

投稿

free_gin
free_gin

スコア8

test CHANGED
@@ -1,36 +1,106 @@
1
1
  ```php
2
+
3
+ $data = array(
4
+
5
+ array("1", "testest", "TESTTEST", "TEST", "TT", "00000", "1", "000000", "0000", "0000", "0000", "0000", "00000", "test" ),
6
+
7
+ array("2", "testest", "TESTTEST", "TEST", "TT", "00000", "1", "000000", "0000", "0000", "0000", "0000", "00000", "test" ),
8
+
9
+ array("3", "testest", "TESTTEST", "TEST", "TT", "00000", "1", "000000", "0000", "0000", "0000", "0000", "00000", "test" ),
10
+
11
+ );
12
+
13
+
14
+
15
+ include(dirname(__FILE__).'/tcpdf/tcpdf.php');
16
+
17
+ include(dirname(__FILE__).'/fpdi/fpdi.php');
18
+
19
+
20
+
21
+ // PDF関連の設定
22
+
23
+ define('ORIENTATION', 'L'); //横向き
24
+
25
+ define('FORMAT', 'A4');
26
+
27
+
28
+
29
+ define('TEMPLATE_FILE', 'test.pdf');
30
+
31
+
32
+
33
+ // 書き込み位置の設定(単位:ミリメートル)
34
+
35
+ define('CELL_TOP', 80);
36
+
37
+ define('CELL_LEFT', 5);
38
+
39
+ define('CELL_HEIGHT', 10);
40
+
41
+
42
+
43
+ $pdf = new FPDI();
44
+
45
+
46
+
47
+ // PDF 設定
48
+
49
+ $pdf->SetMargins(0, 0, 0);
50
+
51
+ $pdf->SetAutoPageBreak(true,15);
52
+
53
+ $pdf->SetCellPadding(0);
54
+
55
+ $pdf->setPrintHeader(false);
56
+
57
+ $pdf->setPrintFooter(false);
58
+
59
+ $pdf->SetFont('kozgopromedium', '', 10);
60
+
61
+ $pdf->AddPage(ORIENTATION, FORMAT);
62
+
63
+
64
+
65
+ // テンプレート関連処理
66
+
67
+ $pdf->setSourceFile(TEMPLATE_FILE);
68
+
69
+ $template = $pdf->importPage(1);
70
+
71
+ $pdf->useTemplate($template, 0, 0);
72
+
73
+
2
74
 
3
75
  //データを書き込む
4
76
 
5
77
  $y = CELL_TOP;
6
78
 
7
-
8
-
9
- foreach($items as $i => $row){
79
+ foreach($data as $i => $row){
10
80
 
11
81
 
12
82
 
13
83
  $pdf->SetXY(CELL_LEFT, $y);
14
84
 
15
- $pdf->Cell(10,10, $row[0], 1, 0, 'C', "", 2, false, 'C', '');
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
- (配列分続く)
24
-
25
- $y += 10;
26
-
27
85
  $pdf->useTemplate($template, 0, 0);
28
86
 
29
87
 
30
88
 
89
+ $pdf->Cell(10, CELL_HEIGHT, $row[1], 0, 0, 'C', "", 2, false, 'C', '');
90
+
91
+ $pdf->Cell(14, CELL_HEIGHT, $row[2], 0, 0, 'C', "", 2, false, 'C', '');
92
+
93
+ $pdf->Cell(12, CELL_HEIGHT, $row[3], 0, 0, 'C', "", 2, false, 'C', '');
94
+
95
+
96
+
97
+ $y += 10;
98
+
31
99
  }
32
100
 
33
101
 
102
+
103
+ $pdf->Output('test.pdf', 'D');
34
104
 
35
105
 
36
106
 
@@ -41,3 +111,7 @@
41
111
  Cellの大きさが一つ一つ違うので個別にCellを書いたところ解決できました。
42
112
 
43
113
  ありがとうございました。
114
+
115
+
116
+
117
+ 追記:最終的なコードを修正しました。