Amiya Ranjan
Amiya Ranjan

Reputation: 177

How to include s3 url inside pdf files dompdf.

My s3 url is 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); 

Upvotes: 3

Views: 2330

Answers (1)

Yevgeniy Afanasyev
Yevgeniy Afanasyev

Reputation: 41360

If you use Laravel, you need to add this to your blade.

@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}}">

if you are not on Laravel, try Embedding images in a PDF file with PHP and DOMPDF

Upvotes: 1

Related Questions