text-align:居中于通过DomPDF(Laravel)生成PDF,向右偏移一点]] << [

问题描述 投票:0回答:1
我使用laravel-dompdf从视图生成pdf。除了“ text-align:center” CSS之外,其他所有东西都可以正常工作。

它与中心对齐,但在右边有点“偏移”。

这是示例PDF输出

enter image description here

如您所见,“ FOTO JAMINAN”,“ as”,“ no rek”和“ FOTO PERIKATAN”文本在右侧有些偏移。

这里是视图

<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <style> .table1 { font-family: sans-serif; color: #232323; border-collapse: collapse; } .table1, th, td { border: 1px solid #999; padding: 8px; width: 300px; } .judul { text-align: center; background-color: blue; color: #ffffff; } </style> </head> <body> <h2>Detail Data Lampiran Foto Jaminan BPKB dan Perikatan</h2> <table style="width: 100%;"> <tr> <td class="judul" colspan="2">FOTO JAMINAN</td> </tr> <tr> <td colspan="2"><center>{{ $datafotobpkb->atasNama }}</center></td> </tr> <tr> <td colspan="2"> <center> {{ $datafotobpkb->noRekening }} </center> </td> </tr> <tr> <td> <center> @if($datafotobpkb->pathJaminanAsli1 !== null) <img width="300" src="{{url($datafotobpkb->pathJaminanAsli1)}}"> @endif </center> </td> <td> <center> @if($datafotobpkb->pathJaminanAsli2 !== null) <img width="300" src="{{url($datafotobpkb->pathJaminanAsli2)}}"> @endif </center> </td> </tr> <tr> <td> <center> @if($datafotobpkb->pathJaminanAsli3 !== null) <img width="300" src="{{url($datafotobpkb->pathJaminanAsli3)}}"> @endif </center> </td> <td> <center> @if($datafotobpkb->pathJaminanAsli4 !== null) <img width="300" src="{{url($datafotobpkb->pathJaminanAsli4)}}"> @endif </center> </td> </tr> <tr> <td> <center> @if($datafotobpkb->pathJaminanAsli5 !== null) <img width="300" src="{{url($datafotobpkb->pathJaminanAsli5)}}"> @endif </center> </td> <td> <center> @if($datafotobpkb->pathJaminanAsli6 !== null) <img width="300" src="{{url($datafotobpkb->pathJaminanAsli6)}}"> @endif </center> </td> </tr> <tr> <td colspan="2" rowspan="3"> {{ $datafotobpkb->rincianAgunan }} </td> </tr> </table> <table style="width: 100%;"> <tr> <td colspan="2" class="judul"> <center> FOTO PERIKATAN </center> </td> </tr> <tr> <td> <center> @if($datafotobpkb->pathPerikatanAsli1 !== null) <img width="300" src="{{url($datafotobpkb->pathPerikatanAsli1)}}"> @endif </center> </td> <td> <center> @if($datafotobpkb->pathPerikatanAsli2 !== null) <img width="300" src="{{url($datafotobpkb->pathPerikatanAsli2)}}"> @endif </center> </td> </tr> <tr> <td> <center> @if($datafotobpkb->pathPerikatanAsli3 !== null) <img width="300" src="{{url($datafotobpkb->pathPerikatanAsli3)}}"> @endif </center> </td> <td> <center> @if($datafotobpkb->pathPerikatanAsli4 !== null) <img width="300" src="{{url($datafotobpkb->pathPerikatanAsli4)}}"> @endif </center> </td> </tr> <tr> <td colspan="2"> {{ $datafotobpkb->atasNama }} </td> </tr> <tr> <td colspan="2"> {{ $datafotobpkb->noRekening }} </td> </tr> <tr> <td colspan="2"> Pokok Hutang:{{ $datafotobpkb->pokokHutang }} / Jangka Waktu : {{ $datafotobpkb->jangkaWaktu }} / Jasa : {{ $datafotobpkb->jasa }} </td> </tr> <tr> <td colspan="2"> Tanggal Perikatan:{{ $datafotobpkb->tglPerikatan }} </td> </tr> </table> </div> </body> </html>

这是控制器功能

public function cetak_pdf($id) { $datafotobpkb = Datafotobpkb::find($id); if($datafotobpkb === null) { abort(404); } $this->check_priviledge($datafotobpkb); $pdf = PDF::loadview('datafotobpkb.datafotobpkb_pdf',['datafotobpkb'=>$datafotobpkb]); // return $pdf->download('datafotobpkb-'.date('Y-m-d-h-i').'.pdf'); return $pdf->stream('datafotobpkb-'.date('Y-m-d-h-i').'.pdf'); }

任何想法如何解决此问题?预先感谢。

我使用laravel-dompdf从视图生成pdf。除了“ text-align:center” CSS之外,其他所有东西都可以正常工作。它与中心对齐,但在右侧有点“偏移”。这是示例PDF ...

php html css laravel dompdf
1个回答
0
投票
我今天遇到了同样的问题。我通过将版本从“ barryvdh / laravel-dompdf”:“ ^ 0.8.4”更新为“ barryvdh / laravel-dompdf”:“ ^ 0.8.5”来解决。
© www.soinside.com 2019 - 2024. All rights reserved.