Dompdf: How to save generated pdf in server

Created on 17 Nov 2016  路  4Comments  路  Source: dompdf/dompdf

I am using dompdf php lib for generating pdf.

Right now it ask user to save the file in their machine.
this is my code,

    $dompdf->loadHtml("myhtml code is here");
    $dompdf->render();
   $dompdf->stream();

What i want is that when user click on the button, it should save the pdf in specific path in server.

How can we configure it.

Pls help.
Thanks in advance

question

Most helpful comment

$dompdf->loadHtml("myhtml code is here");
$dompdf->render();

$output = $dompdf->output();
file_put_contents('filename.pdf', $output);

Questions should be asked on the user forum, not in the bug tracker.

All 4 comments

+1

$dompdf->loadHtml("myhtml code is here");
$dompdf->render();

$output = $dompdf->output();
file_put_contents('filename.pdf', $output);

Questions should be asked on the user forum, not in the bug tracker.

The above code will upload to the remote location, however it is _also_ downloading the file as well. Is it possible to have it upload, and not download at the same time?

    $dompdf = new Dompdf();
    // $dompdf->loadHtml($html);


    $dompdf->loadHtml(html_entity_decode($html));


    // (Optional) Setup the paper size and orientation
    $dompdf->setPaper('A4', 'portrait');
    $dompdf->render();
    $output = $dompdf->output();
    file_put_contents($filePath, $output);

@bdbolin that does not also send the file to the browser. $dompdf->stream() sends the file to the browser. $dompdf->output() only retrieves the source of the PDF.

Also, as mentioned in an earlier response, questions should be asked on the user forum, not in the bug tracker. You can always add links for context.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

enjibby picture enjibby  路  4Comments

doanvandoana8 picture doanvandoana8  路  4Comments

PhenX picture PhenX  路  3Comments

jewei picture jewei  路  4Comments

nuez picture nuez  路  3Comments