samedi 18 novembre 2017

Laravel 5: Output tFPDF

I want to use tFPDF in Laravel 5.5. I added the package with composer and then I tried to output it the according to the docs but nothing worked.

I tried to output it directly to the browser:

Route::get('/test',function(){
        $pdfLibrary = new tFPDF\PDF();
       $pdfLibrary->AddPage();

       $pdfLibrary->AddFont('DejaVuSansCondensed', '', 'DejaVuSansCondensed.ttf', true);
       $pdfLibrary->SetFont('DejaVuSansCondensed', '', 14);

       $pdfLibrary->Write(8, 'Hallo!');
       $pdfLibrary->output();           
});

but the sceen was just blank. When I tried return $pdfLibrary->output(); then it just returned

%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream x�u�� �@S�)>+�p�.......

I also tried to simply save the pdf to a file, but even

$pdfLibrary->output('F', storage_path() . '/test.pdf');

did not work.

How can I save & output the pdfs created by tFPDF ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2itXVMT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire