我的s3网址https://s3-us-west-2.amazonaws.com/bucket_name/test.png

its working fine on browser and showing image not found after including it on pdf file.

$pdf = new \DOMPDFModule\View\Model\PdfModel();
$pdf->setOption("filename", $filename);
$pdf->setOption("paperSize", "a4");
$pdf->setOption("paperOrientation", "landscape");
$dompdf = new \DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$pdfCode = $dompdf->output();
file_put_contents('path_to_pdf/test.pdf', $pdfCode);

最佳答案

如果你使用拉维,你需要添加到你的刀片。

@php
    use Illuminate\Support\Facades\Storage;
    $content = Storage::get('vinylmaster.png');
    $imageData = base64_encode($content);
    $src = 'data:image/png;base64,' . $imageData;
@endphp

<img src="{{$src}}">

如果您不在laravel上,请尝试Embedding images in a PDF file with PHP and DOMPDF

关于php - 如何在pdf文件dompdf中包含s3网址。,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42851091/

10-13 05:30