Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCPDF Save file to folder?

Tags:

php

tcpdf

People also ask

What is TCPDF error?

Any error stating 'TCPDF' means that there was a problem with the generation of the PDF file.


try this

$pdf->Output('kuitti'.$ordernumber.'.pdf', 'F');

this stores the generated pdf file in your custom folder of your project

$filename= "{$membership->id}.pdf"; 
$filelocation = "D:\\wamp\\www\\project\\custom";//windows
$filelocation = "/var/www/project/custom"; //Linux

$fileNL = $filelocation."\\".$filename;//Windows
$fileNL = $filelocation."/".$filename; //Linux

$this->pdf->Output($fileNL, 'F');

$pdf->Output() takes a second parameter $dest, which accepts a single character. The default, $dest='I' opens the PDF in the browser.

Use F to save to file

$pdf->Output('/path/to/file.pdf', 'F')

Only thing that worked for me:

// save file
$pdf->Output(__DIR__ . '/example_001.pdf', 'F');
exit();

For who is having difficulties storing the file, the path has to be all the way through root. For example, mine was:

$pdf->Output('/home/username/public_html/app/admin/pdfs/filename.pdf', 'F');