Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

melx's avatar
Level 4

Return pdf file in binary

am using dompdf/dompdf package, so i want to return the pdf binary file via api

kindly advice what can i do

                       $pdf = PDF::loadView('waybill-track.waybillprogresspdf', compact('waybilltrack','items'));

                        return $pdf->stream('waybilllable.pdf', array('Attachment' => 0));
0 likes
2 replies
petrit's avatar

This will return base64, maybe this is will work for you

return 'data:application/pdf;base64,'.base64_encode($pdf->stream());

Please or to participate in this conversation.