質問編集履歴

2

$data変数追加、セミコロンとarrayの中の,を追加しました。

2019/10/05 04:46

投稿

free_gin
free_gin

スコア8

test CHANGED
File without changes
test CHANGED
@@ -14,13 +14,13 @@
14
14
 
15
15
  ```PHP
16
16
 
17
- array(
17
+ $data = array(
18
18
 
19
- array("1","氏名","電話番号","00000000")
19
+ array("1","氏名","電話番号","00000000"),
20
20
 
21
- array("1","太郎","090000066666","00000000")
21
+ array("1","太郎","090000066666","00000000"),
22
22
 
23
- )
23
+ );
24
24
 
25
25
 
26
26
 
@@ -70,7 +70,7 @@
70
70
 
71
71
 
72
72
 
73
- foreach($items as $i => $row){
73
+ foreach($data as $i => $row){
74
74
 
75
75
 
76
76
 

1

コードが正常に動くように修正しました。失礼しました。

2019/10/05 04:46

投稿

free_gin
free_gin

スコア8

test CHANGED
File without changes
test CHANGED
@@ -12,27 +12,57 @@
12
12
 
13
13
 
14
14
 
15
- AddPage()のif文もおかしな状態になってるコードで申し訳ありませんが、
16
-
17
- ご教授くさい。
18
-
19
-
20
-
21
15
  ```PHP
22
16
 
23
17
  array(
24
18
 
25
- array(数個のデータ)
19
+ array("1","氏名","電話番号","00000000")
26
20
 
27
- array(数個のデータ)
21
+ array("1","太郎","090000066666","00000000")
28
-
29
-
30
-
31
-
32
-
33
-
34
22
 
35
23
  )
24
+
25
+
26
+
27
+ include(dirname(__FILE__).'tcpdf/tcpdf.php');
28
+
29
+ include(dirname(__FILE__).'fpdi/fpdi.php');
30
+
31
+
32
+
33
+ // AddPage 引数
34
+
35
+ $orientation = 'L';
36
+
37
+ $format = 'A4';
38
+
39
+
40
+
41
+ $pdf = new FPDI();
42
+
43
+ $pdf->SetMargins(0,0,0); // 上左右マージンの設定
44
+
45
+ $pdf->SetCellPadding(0); // セルパディングの設定
46
+
47
+ $pdf->SetAutoPageBreak(false); // 自動改ページを無効
48
+
49
+ $pdf->setPrintHeader(false); // ページヘッダ無効
50
+
51
+ $pdf->setPrintFooter(false); // ページフッタ無効
52
+
53
+
54
+
55
+ $pdf->setSourceFile('test.pdf'); // テンプレートを読み込み
56
+
57
+ $template = $pdf->importPage(1);
58
+
59
+ $pdf->AddPage($orientation, $format);
60
+
61
+ $pdf->useTemplate($template, 0, 0);
62
+
63
+ $pdf->SetFont('kozgopromedium', '', 12);
64
+
65
+
36
66
 
37
67
  // データを書き込む
38
68
 
@@ -64,14 +94,14 @@
64
94
 
65
95
  $y += 10;
66
96
 
67
- if($i == 11){
68
97
 
69
- $pdf->AddPage($orientation, $format);
70
-
71
- $pdf->useTemplate($template, 0, 0);
72
-
73
- }
74
98
 
75
99
  }
76
100
 
101
+
102
+
103
+
104
+
105
+ $pdf->Output('test.pdf','D');
106
+
77
107
  ```