Wednesday, 20 February 2019

add at end of TCPDF to save file in folder

$pdf->writeHTML($txt, true, false, true, false, '');
//=============
$limit = 4;
$digit_str   = '0123456789';
$digit = substr(str_shuffle($digit_str), 0, $limit);
//======================
$letter_str='abcdefhigklmnopqrstuvwxyz';
$letter = substr(str_shuffle($letter_str), 0, $limit);
//==================
$filename="LGHT$digit$letter.pdf";
//$dir='/var/www/html/pdf/pdf_files/';
$dir= $_SERVER["DOCUMENT_ROOT"].'param/temp_reports/';
/*PDF info page */
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Lighthouse247');
$pdf->SetTitle($filename);
$pdf->SetSubject('INVOICE Lighthouse247');
//$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
/*Save pdf file to folder*/
$pdf->Output($dir.$filename, 'F');
//$download_link = "http://$_SERVER[HTTP_HOST]/pdf/pdf_files/$filename";
//$download_link = $_SERVER['HTTP_HOST']."/pdf_files/$filename";
$download_link = "http://localhost/param/temp_reports/$filename";

/*Apear Download link on screen*/
echo $result="<a href='$download_link' download>
  <img src='pdf.png' alt='download' width='104' height='142'>
</a>";

No comments:

Post a Comment