DOMPDF Set Download Location

Asked

Viewed 492 times

0

Good morning guys. I was wondering how do I set the download destination location of the dompdf function.

//Para realizar o download somente alterar para true
$dompdf->stream("documento_para_download.pdf", array("Attachment" => false));

I’m not sure if there is any structure that goes on this line q is next to the context of the pdf that is available here:

//referenciar o DomPDF com namespace
use Dompdf\Dompdf;

// include autoloader
require_once("dompdf/autoload.inc.php");

//Criando a Instancia
$dompdf = new DOMPDF();

// Carrega seu HTML
$dompdf->load_html('');
/Renderizar o html
$dompdf->render();

//Exibibir a página
//Para realizar o download somente alterar para true
$dompdf->stream(documento_para_download.pdf", array("Attachment" => false));

And then comes the file information. I just need to tell him where to save

  • 2

    You have no way to tell the client where it will force the download by stream, will always save where the user says to save, you can only set the location on your server, client-side no.

  • if I am on my server I can say $dompdf->stream(folder/doc/document_para_download.pdf", array("Attachment" =>true));

1 answer

-2

 file_put_contents(("C:/wamp64/www/geraDoc - Beta2 final/DocumentosGerados/".$clienteId."/Carta de notificação.pdf"), $dompdf->output());

o C:/wamp64/www/geraDoc - Beta2 final/Documentsgerados/". $clienteId." /Notification letter.pdf" refers to the path in which you want to save the file.

  • Hello Moreira. The author of the question that define the download path, this above code saved on the server and not the download, are different things. PHP runs on an HTTP server, communication is client x server, not in the same place. What the author wants is also impossible, who decides where to save on the client side is the user himself.

Browser other questions tagged

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