src/Service/pdfService.php
public function output($domPdf)
    {
        //$tmpfile = getcwd()."/tmpfiles";
        $tmpDir = OPENBIZ_APP_PATH."/tmpfiles";
        //echo $tmpfile;
        $this->cleanFiles($tmpDir, 100);
        //Determine a temporary file name in the current directory
        $tmpFile = tempnam($tmpDir,'tmp');
        $fileName = $tmpFile.'.pdf';
        $fileName = str_replace("\\","/",$fileName);
        unlink($tmpFile);
        //Save PDF to file
        $pdfText = $domPdf->output();
        $fileHandle = fopen($fileName, 'w') or die("can't open pdf file to write");
        fwrite($fileHandle, $pdfText) or die("can't write to the pdf file");
        fclose($fileHandle);
        //JavaScript redirection
        $path_parts = pathinfo($fileName);
        $file_download = "tmpfiles/".$path_parts['basename'];
        echo "<HTML><BODY onload=\"window.location.href='../$file_download';\"</BODY></HTML>";
    }
public function output($domPdf)
    {
        //$tmpfile = getcwd()."/tmpfiles";
        $tmpDir = OPENBIZ_APP_PATH."/tmpfiles";
        //echo $tmpfile;
        $this->cleanFiles($tmpDir, 100);
        //Determine a temporary file name in the current directory
        $tmpFile = tempnam($tmpDir,'tmp');
        $fileName = $tmpFile.'.pdf';
        $fileName = str_replace("\\","/",$fileName);
        unlink($tmpFile);
        //Save PDF to file
        $pdfText = $domPdf->output();
        $fileHandle = fopen($fileName, 'w') or die("can't open pdf file to write");
        fwrite($fileHandle, $pdfText) or die("can't write to the pdf file");
        fclose($fileHandle);
        //JavaScript redirection
        $path_parts = pathinfo($fileName);
        $file_download = "tmpfiles/".$path_parts['basename'];
        echo "<HTML><BODY onload=\"window.location.href='../$file_download';\"</BODY></HTML>";
    }
Save PDF to file and inform download link to client

@param DOMPDF $domPdf