DOMPDF Save/Download file to client

Asked

Viewed 20 times

0

I am using dompdf, I need to download the file automatically, how to do this?

I’m using the code below:

 $dompdf = new DOMPDF ();
 $dompdf->load_html($resultado[0]['recibo']);
 $dompdf->render();
 $dompdf->stream("Recibo.pdf", array("Attachment" => true));

It was to open the dialog to save the file, but I’m getting the following error:

Unable to stream pdf: headers already sent

Pq?

  • "headers already sent" means that there is something before your DOMPDF that is being sent together in the download, maybe an echo, a print, or even HTML. In other words, DOMPDF has to be executed on a page that does not have any other content, such as HTML or text, only DOMPDF itself.

  • Any alternative to DOMPDF? Ta fuck use it here.

  • 1

    It is not the fault of DOMPDF and you will not be able to solve the problem using another lib, read: https://answall.com/a/18812/3635

  • I decided to take a $_GET that passed empty

  • 1

    Yes, $_GET should issue a Warning before the Location header, then the error, text or HTML content before the DOMPDF and Location header.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.