
本番環境とテスト環境の2つのサーバーで、全く同一のPHPを走らせてTCPDFでPDF帳票を出力しています。
サーバーは両方ともConohaのVPSで、イメージ保存→復元で複製したものになります。
(但しドメイン周り、SSLの情報は適宜変更をしています)
テスト環境では、
PHP
1$tcpdf->Output('tag.pdf', 'I');
で出力したPDF上で右クリック→ファイル名を付けて保存 で、tag.pdfが問題なく保存できますが、
本番環境ではなぜか、同様に保存しようとすると tag.php(PDFを書き出しさせてるPHPのファイル名)の保存になってしまいます。
なお保存されたファイルを開いてみると.phpの中身ではなく、同スクリプトでPOST値がない場合に出力しているHTMLでした。
なおPDFの表示自体は本番環境でも問題なくブラウザ上でできており、印刷にも支障ありません。
原因がわからず困惑しております。。お知恵をお貸し下さい。
以下、コード全文です。
PHP
1<?php 2 3//---自作関数集 4 require_once __DIR__ .'/lib/function.php'; 5 6//---基礎設定ファイル 7 require_once __DIR__ .'/lib/config.php'; 8 9if($_SESSION['login']['veryfy'] == true): 10 if($_POST): 11 if($_POST['数量']<=0): 12 echo "<script>window.close();</script>";//新規タブで開いているので、有効な値がない場合はタブを閉じる 13 exit; 14 endif; 15 $i=1; 16 $row = 1; 17 $col = 1; 18 $p = 1; 19 $i = 1; 20 $pages = 0; 21 $remain = $_POST['数量']; 22 while($remain>0): 23 if($remain>=$_POST['入数']): 24 $data[$p][$row][$col]['page'] = $i; 25 $data[$p][$row][$col]['入数'] = $_POST['入数']; 26 else://最終ページ 27 $data[$p][$row][$col]['page'] = $i; 28 $data[$p][$row][$col]['入数'] = $remain; 29 endif; 30 $remain -=$data[$p][$row][$col]['入数']; 31 ++$i; 32 ++$pages; 33 ++$col; 34 if($col==3): 35 $col = 1; 36 ++$row; 37 endif; 38 if($row==5 AND $remain>=1): 39 $row = 1; 40 ++$p; 41 endif; 42 endwhile; 43 44 if($col==2): 45 $data[$p][$row][$col]['page'] = 'End'; 46 endif; 47 require_once __DIR__ .'/libs/tcpdf/tcpdf.php'; 48 $tcpdf = new TCPDF(); 49 $tcpdf->setPrintHeader(false); 50 $tcpdf->setPrintFooter(false); 51 $tcpdf->SetTitle($config['sys_name'].' 現品票'); 52 $tcpdf->SetAuthor($config['sys_name']); 53 54 $line_style = array(); 55 $line_style['width'] = 0.2; 56 foreach($data as $page_num=>$pagedata): 57 $x = 5; 58 $y = 5; 59 $tcpdf->AddPage(); 60 $tcpdf->SetAutoPageBreak(true, 5); 61 $tcpdf->SetFont("kozgopromedium", "", 8); 62 foreach($pagedata as $row_num=>$row): 63 foreach($row as $col_num=>$tag): 64 if($tag['page']!='End'): 65 if($col_num==2): 66 $x = $x+95+10; 67 endif; 68 //外枠 69 $tcpdf->SetXY($x,$y,true); 70 $tcpdf->cell(95,64.25,'',1); 71 //現品票 72 $tcpdf->SetXY($x,$y,true); 73 $tcpdf->cell(23.75,22.5,'',1,0,'C',false,'',1,false,'T','T'); 74 $tcpdf->SetXY($x,$y+1,true); 75 $tcpdf->cell(23.75,20.5,'現品票',0,0,'C',false,'',1,false,'T','T'); 76 //品名 77 $tcpdf->SetXY($x+23.75,$y,true); 78 $tcpdf->cell(11.875,12.5,'品 名',1,0,'C',false,'',1,false,'T','M'); 79 $tcpdf->SetXY($x+23.75+11.875,$y,true); 80 $tcpdf->SetFont("kozgopromedium", "", 25); 81 $tcpdf->cell(59.375,12.5,$_POST['機種名'],1,0,'C',false,'',1,false,'T','M'); 82 $tcpdf->SetFont("kozgopromedium", "", 8); 83 //品番 84 $tcpdf->SetXY($x+23.75,$y+12.5,true); 85 $tcpdf->cell(11.875,10,'品 番',1,0,'C',false,'',1,false,'T','M'); 86 $tcpdf->SetXY($x+23.75+11.875,$y+12.5,true); 87 $tcpdf->SetFont("kozgopromedium", "", 22); 88 $tcpdf->cell(59.375,10,$_POST['品目コード'],1,0,'C',false,'',1,false,'T','M'); 89 $tcpdf->SetFont("kozgopromedium", "", 8); 90 //製造日 91 $tcpdf->SetXY($x,$y+22.5,true); 92 $tcpdf->cell(11.875,10,'製造日',1,0,'C',false,'',1,false,'T','M'); 93 $tcpdf->SetXY($x+11.875,$y+22.5,true); 94 $tcpdf->cell(35.625,10,'',1,0,'C',false,'',1,false,'T','M'); 95 //No 96 $tcpdf->SetXY($x+47.5,$y+22.5,true); 97 $tcpdf->cell(11.875,10,'',1,0,'C',false,'',1,false,'T','M'); 98 $tcpdf->SetXY($x+49,$y+22.5,true); 99 $tcpdf->cell(10.375,10,'No.',0,0,'C',false,'',1,false,'T','M'); 100 $tcpdf->SetXY($x+47.5+11.875,$y+22.5,true); 101 $tcpdf->SetFont("kozgopromedium", "", 22.5); 102 $tcpdf->cell(20,10,$tag['page'],'B',0,'R',false,'',1,false,'T','M'); 103 $tcpdf->SetFont("kozgopromedium", "", 10); 104 $tcpdf->SetXY($x+47.5+11.875+20,$y+22.5,true); 105 $tcpdf->cell(15.625,10,'','B',0,'L',false,'',1,false,'T','M'); 106 $tcpdf->SetXY($x+47.5+11.875+20,$y+22.5+4,true); 107 $tcpdf->cell(15.625,4,'/'.$pages,0,0,'L',false,'',1,false,'T','M'); 108 $tcpdf->SetFont("kozgopromedium", "", 8); 109 //ハコガエ 110 $tcpdf->SetXY($x,$y+32.5,true); 111 $tcpdf->cell(23.75,5,'ハコガエ',1,0,'C',false,'',1,false,'T','M'); 112 //検査 113 $tcpdf->SetXY($x+23.75,$y+32.5,true); 114 $tcpdf->cell(23.75,5,'検 査',1,0,'C',false,'',1,false,'T','M'); 115 $tcpdf->SetXY($x+23.75,$y+37.5,true); 116 $tcpdf->cell(23.75,19.75,'',1,0,'C',false,'',1,false,'T','M'); 117 //入数 118 $tcpdf->SetXY($x+23.75+23.75,$y+32.5,true); 119 $tcpdf->cell(23.75,5,'入 数',1,0,'C',false,'',1,false,'T','M'); 120 $tcpdf->SetXY($x+23.75+23.75,$y+37.5,true); 121 $tcpdf->SetFont("kozgopromedium", "", 32); 122 $tcpdf->cell(23.75,19.75,$tag['入数'],1,0,'C',false,'',1,false,'T','M'); 123 $tcpdf->SetFont("kozgopromedium", "", 8); 124 $tcpdf->SetXY($x+23.75+23.75,$y+37.5,true); 125 $tcpdf->cell(23.75,19,'/'.$_POST['入数'],0,0,'R',false,'',1,false,'T','B'); 126 //備考 127 $tcpdf->SetXY($x+23.75+23.75+23.75,$y+32.5,true); 128 $tcpdf->cell(23.75,5,'備 考',1,0,'C',false,'',1,false,'T','M'); 129 $tcpdf->SetXY($x+23.75+23.75+23.75,$y+37.5,true); 130 $tcpdf->cell(23.75,19.75,'',1,0,'C',false,'',1,false,'T','M'); 131 //材料名 132 $tcpdf->SetXY($x+23.75,$y+57.25,true); 133 $tcpdf->cell(71.25,7,'材料名:',1,0,'L',false,'',1,false,'T','M'); 134 135 $x = 5; 136 endif; 137 endforeach; 138 $y = $y + 64.25 + 10; 139 endforeach; 140 endforeach; 141 $tcpdf->Output('tag.pdf', 'I');//生成したPDFをブラウザ上で表示させる 142 exit; 143 endif; 144 145 $line_list = get_line_list($config); 146 foreach($line_list as $sort=>$val): 147 $line_code = $val['code']; 148 $data[$sort] = get_product_list($line_code); 149 endforeach; 150 151 $smarty->assign('msg',$msg); 152 $smarty->assign('line_list',$line_list); 153 $smarty->assign('auth',$_SESSION['login']['auth']); 154 $smarty->assign('data',$data); 155 $smarty->display('tag.html'); 156else: 157 $smarty->display('index.html'); 158endif; 159exit; 160?> 161


回答2件
あなたの回答
tips
プレビュー