0
votes

i want to save the output pdf file to public folder my method is

public function qrSVG()
{
    $qrCodes = ['4659284fff','465928447','465928447','613271980','484016586','aaaaabbbbbccccc'];
    $id = ['201596400-1','201596400-2','201596400-3','831070646','493130428','aaaaabbbb'];


    PDF::SetTitle('qrcodes\test');

    $i=0;
    foreach(array_chunk($qrCodes, 2) as $qrCodee)
    {
        PDF::AddPage();
        $m = 55;
        $n = 30;
        foreach($qrCodee as $qr)
        {
            QrCode::size(400);
            QrCode::margin(3);
            QrCode::errorCorrection('H');
            QrCode::encoding('UTF-8');
            QrCode::backgroundColor(255,255,255);
            QrCode::color(0,0,0);
            QrCode::imageTitle($id[$i]);  
            $svg = QrCode::generate($qr);
            PDF::ImageSVG('@'.$svg, $x=$m, $y=$n, $w='100', $h='100', $link='', $align='', $palign='', $border=1, $fitonpage=false);
            $i++;
            $n = 150;
        }    
    }    
    ob_clean();
    PDF::Output('qrcodes\test.pdf');}

this code generate and open the file put don't save it when i replace the last line in my code with PDF::Output('qrcodes\test.pdf', 'F'); when i put any option with PDF::Output there is an error with F and D options the error when use F is ErrorException in tcpdf_static.php line 2440: fopen(): remote host file access not supported, file://qrcodes\test.pdf and when i replace the last line with

PDF::Output($_SERVER['DOCUMENT_ROOT'] . 'qrcodes\test.pdf', 'F');

the error is ErrorException in tcpdf.php line 2793: Undefined property: Elibyy\TCPDF\Pdf::$h

1

1 Answers

0
votes

The main reason you're getting the error about remote host file access not supported is because you need to provide the full path in the file name that you provide to the Output() method. Yeah, it's a bit annoying and it catches me out all the time!

I can't comment on the second error you're getting because I cannot get your code to run (missing methods in QrCode class). What version are you using? Also, why are you trying to create an SVG for the QR code and then adding that to the PDF? Instead of taking that approach, I would highly recommend following the approach illustrated in this example:

https://github.com/tecnickcom/TCPDF/blob/master/examples/example_050.php

As you will see in the example, you should create an instance of the TCPDF class and then work with that instance, rather than calling the static methods.