TCPDF Save file to folder?

后端 未结 11 1982
耶瑟儿~
耶瑟儿~ 2020-12-13 07:05

I\'m using TCPDF to print a receipt and then send it to customer with phpMailer, but I have a problem:

I have no idea how to save the file into a pdf.

相关标签:
11条回答
  • 2020-12-13 07:28

    This worked for me, saving to child dir(temp_pdf) under the root:

    $sFilePath = $_SERVER['DOCUMENT_ROOT'] . '//temp_pdf/file.pdf' ;
    $pdf->Output( $sFilePath , 'F');
    

    Remember to make the dir writeable.

    0 讨论(0)
  • 2020-12-13 07:31

    $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')
    
    0 讨论(0)
  • 2020-12-13 07:34

    You may try;

    $this->Output(/path/to/file);
    

    So for you, it will be like;

    $this->Output(/kuitit/);  //or try ("/kuitit/")
    
    0 讨论(0)
  • 2020-12-13 07:36

    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');
    
    0 讨论(0)
  • 2020-12-13 07:37
    $pdf->Output( "myfile.pdf", "F");
    

    TCPDF ERROR: Unable to create output file: myfile.pdf

    In the include/tcpdf_static.php file about 2435 line in the static function fopenLocal if I delete the complete 'if statement' it works fine.

    public static function fopenLocal($filename, $mode) {
        /*if (strpos($filename, '://') === false) {
            $filename = 'file://'.$filename;
        } elseif (strpos($filename, 'file://') !== 0) {
            return false;
        }*/
        return fopen($filename, $mode);
    }
    
    0 讨论(0)
提交回复
热议问题