【发布时间】:2022-01-07 01:49:38
【问题描述】:
我想用 dompdf 导出回顾数据,我使用的是来自 dompdf 的loadHTML(),在视图中我使用的是<img src"file.svg">,但图像输出不知何故失真。这是dompdf的代码
export.php
$reports = $this->getReports($request); extract($request->all());
$html = view('pdf/rekap-lp')->with(compact('reports', 'start_date', 'end_date'))->render();
$this->createQRCODE($reports);
$pdf = \App::make('dompdf.wrapper');
$pdf->setPaper('A4', 'portrait');
$pdf->loadHTML($html);
$pdf->setOptions(['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true]);
return $pdf->stream(uniqid().'.pdf');
这里是风景
<tr style="font-size: 13px">
<td class="text-center">{{ $loop->iteration }}</td>
<td>{{ (ucfirst($item->dugaan_pelanggaran)) ?: '-' }}</td>
<td class="text-center no-wrap">
{{ (strftime('%d %B %Y', strtotime($item->tanggal_laporan))) ?: '-' }}
</td>
<td>{{ (ucfirst($item->kronologis)) ?: '-' }}</td>
<td>{{ (ucfirst($item->lokasi)) ?: '-' }}</td>
<td>{{ (ucfirst($item->satker)) ?: '-' }}</td>
<td>
<img src="{{ asset('img/qr-code/lp/' . $item->id_lp .'.svg') }}" >
</td>
</tr>
更新
我刚刚发现,如果我用http://localhost/detail/100这样的url生成二维码,二维码会失真,但如果我用字符串This is a very cool website生成二维码,显示的二维码是正常的,不会失真
【问题讨论】:
-
file.svg 中有什么?
-
@RobertLongson 带有 URL 的二维码
-
我的意思是,请编辑问题并添加file.svg的标记。