3

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); 
Amiya Ranjan
  • 177
  • 10
  • what have u tried so far? – NID Mar 17 '17 at 07:01
  • Have you confirmed that dompdf has read/write access to the temp directory specified in your configuration? Do you get any error messages (i.e. from PHP)? – BrianS Mar 17 '17 at 17:33
  • 1
    PDF created successfully but its showing image not found with cross sign. I'm also included images that are present in local server, its working fine. issue only with s3 images. Thanks – Amiya Ranjan Mar 22 '17 at 07:52
  • you can try my solution . you need to check this..... https://stackoverflow.com/questions/15153139/dompdf-remote-image-is-not-displaying-in-pdf/75243734#75243734 – pankaj Jan 26 '23 at 08:35

1 Answers1

1

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

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191