Laravel Snappy PDF 如何显示图片
Laravel Snappy PDF How to show images
我遇到了 snappy 包的问题。我正在尝试使用外部图像生成 pdf,但执行此操作时出现错误:
$pdf = PDF::loadView('admin-customer.tag.pdf-view', $product)
->setOption('page-width', '100')
->setOption('page-height', '70.5')
->setOption('margin-top', 2)
->setOption('margin-bottom', 2)
->setOption('margin-left', 2)
->setOption('margin-right', 2);
return $pdf->download($product->name . '.pdf');
我的看法:
<div class="qrcode">
<img src="//api.qrserver.com/v1/create-qr-code/?data=http://trackagro.com.br" alt="">
<h6 class="msg">
CONSULTE PELO SEU LEITOR DE QR-CODE OU EM NOSSO SITE TRACKAGRO.COM.BR
</h6>
</div>
错误:
Page 1 of 1 Done Exit with code 1 due to network error: ContentNotFoundError " stdout: "" command: D:\Projects\empresas\trackagro\trackagro-sistema\vendor\wemersonjanuario\wkhtmltopdf-windows\binbit\wkhtmltopdf --lowquality --margin-bottom "2" --margin-left "2" --margin-right "2" --margin-top "2" --page-height "70.5" --page-width "100" "C:\Users\PopApps\AppData\Local\Temp\knp_snappy5dcaeaf096db73.71503659.html" "C:\Users\PopApps\AppData\Local\Temp\knp_snappy5dcaeaf09905f2.88209190.pdf".
我一直在研究并设法解决使用另一个库生成 qrcode,它生成 SVG 中的图像:
https://www.simplesoftware.io/simple-qrcode/
还有我的代码:
$pdf = PDF::loadView('admin-customer.tag.pdf-view', $product)
->setOption('page-width', '100')
->setOption('page-height', '70.5')
->setOption('margin-top', 2)
->setOption('margin-bottom', 2)
->setOption('margin-left', 2)
->setOption('margin-right', 2)
->setOption('images', true);
return $pdf->download($product->name . '.pdf');
而我的观点:
<img src="data:image/png;base64, {{ base64_encode(QrCode::format('png')->size(100)->generate('http://trackagro.com.br')) }}" />
非常感谢
我遇到了 snappy 包的问题。我正在尝试使用外部图像生成 pdf,但执行此操作时出现错误:
$pdf = PDF::loadView('admin-customer.tag.pdf-view', $product)
->setOption('page-width', '100')
->setOption('page-height', '70.5')
->setOption('margin-top', 2)
->setOption('margin-bottom', 2)
->setOption('margin-left', 2)
->setOption('margin-right', 2);
return $pdf->download($product->name . '.pdf');
我的看法:
<div class="qrcode">
<img src="//api.qrserver.com/v1/create-qr-code/?data=http://trackagro.com.br" alt="">
<h6 class="msg">
CONSULTE PELO SEU LEITOR DE QR-CODE OU EM NOSSO SITE TRACKAGRO.COM.BR
</h6>
</div>
错误:
Page 1 of 1 Done Exit with code 1 due to network error: ContentNotFoundError " stdout: "" command: D:\Projects\empresas\trackagro\trackagro-sistema\vendor\wemersonjanuario\wkhtmltopdf-windows\binbit\wkhtmltopdf --lowquality --margin-bottom "2" --margin-left "2" --margin-right "2" --margin-top "2" --page-height "70.5" --page-width "100" "C:\Users\PopApps\AppData\Local\Temp\knp_snappy5dcaeaf096db73.71503659.html" "C:\Users\PopApps\AppData\Local\Temp\knp_snappy5dcaeaf09905f2.88209190.pdf".
我一直在研究并设法解决使用另一个库生成 qrcode,它生成 SVG 中的图像: https://www.simplesoftware.io/simple-qrcode/
还有我的代码:
$pdf = PDF::loadView('admin-customer.tag.pdf-view', $product)
->setOption('page-width', '100')
->setOption('page-height', '70.5')
->setOption('margin-top', 2)
->setOption('margin-bottom', 2)
->setOption('margin-left', 2)
->setOption('margin-right', 2)
->setOption('images', true);
return $pdf->download($product->name . '.pdf');
而我的观点:
<img src="data:image/png;base64, {{ base64_encode(QrCode::format('png')->size(100)->generate('http://trackagro.com.br')) }}" />
非常感谢