##わからないこと
いつもお世話になっております。
この度PDFに出力するテーブルにて、その項目が一行ずれてしまいます。
※左上のテーブルです
htmlのコードは以下になります
html
1<head> 2<meta charset="UTF-8"> 3<style> 4table { 5 border-collapse:collapse; 6} 7.text-center{ 8 text-align: center; 9} 10</style> 11</head> 12<table style="margin-left: auto;margin-right: auto;"> 13 <tbody> 14 <tr> 15 <td> 16 <table border="1"> 17 <thead> 18 <tr> 19 <td colspan="2">支 給 額</td> 20 </tr> 21 </thead> 22 <tbody> 23 @foreach($supplies as $supply) 24 <tr> 25 <td style="width:150px;">{{$supply['name']}}</td> 26 <td style="width:100px;">{{$supply['price']}}</td> 27 </tr> 28 @endforeach 29 </tbody> 30 </table> 31 </td> 32 <td> 33 <table border="1"> 34 <thead> 35 <tr> 36 <td colspan="2">控 除 額</td> 37 </tr> 38 </thead> 39 <tbody> 40 @foreach($deductions as $deducntion) 41 <tr> 42 <td style="width:150px;">{{$deducntion['name']}}</td> 43 <td style="width:100px;">{{$deducntion['price']}}</td> 44 </tr> 45 @endforeach 46 </tbody> 47 </table> 48 </td> 49 </tr> 50 <tr> 51 <td> 52 <table border="1"> 53 <thead> 54 <tr> 55 <td colspan="2">控 除 額</td> 56 </tr> 57 </thead> 58 <tbody> 59 @foreach($deductions as $deducntion) 60 <tr> 61 <td style="width:150px;">{{$deducntion['name']}}</td> 62 <td style="width:100px;">{{$deducntion['price']}}</td> 63 </tr> 64 @endforeach 65 </tbody> 66 </table> 67 </td> 68 69 </tr> 70 </tbody> 71</table> 72 73
##追記
htmlのコードを修正しました。
「
table {
border-collapse:collapse;
}
」
の箇所をコメントアウトしたところ、行のズレが解消されました。
そのため文字化けは関係ないように思われます
###php
php
1$params = 'あいう'; 2header('Content-Type: application/pdf'); 3 header('Content-Disposition: attachment;filename="'.$params.'給与明細.pdf"'); 4 header('Cache-Control: max-age=0'); 5 // * 6 $pdf = PDF::loadHTML(view('my.pdf', [ 7 'supplies' => $sDetails, 8 'deductions' => $dDetails 9 ])->render()); 10 $pdf->getDomPDF()->set_option('enable_font_subsetting', true); 11 error_reporting(0); 12 $pdf->save('php://output'); 13 error_reporting(E_ALL); 14 exit; 15
##追記②
border-collapseをコメントアウトしたところ、下の画像のようになりました。
また、出力する配列は下記のようになっています
配列①$sDetails array:3 [▼ 0 => array:7 [▼ "name" => "基本" "price" => 1400 ] 1 => array:7 [▼ "name" => "法" "price" => 1750 ] 2 => array:6 [▼ "name" => "定期" "price" => 9230 ] ] 配列②$dDetails array:5 [▼ 0 => array:6 [▼ "name" => "健" "price" => -7968 ] 1 => array:6 [▼ "name" => "介" "price" => -1264 ] 2 => array:6 [▼ "name" => "厚" "price" => -14546 ] 3 => array:6 [▼ "name" => "保険" "price" => -868 ] 4 => array:6 [▼ "name" => "泉" "price" => -4200 ] ]
上記のずれはどのようにすれば解消できますでしょうか。
何卒よろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー