Skip to content
Advertisement

FPDF string output

I use OctoberCms (laravel). This uses own Filesystem https://octobercms.info/docs/services-filesystem-cdn/ That is why I need to take generated $pdf as a string, and than use Storage::put('docs/kek.pdf', $pdf);

    public function onGeneratePdf() {  
        $pdf = new FPDF();
        $pdf->AddPage();
        $pdf->SetFont('Arial','B',16);
        $pdf->Cell(40,10,'Hello World!');    
        $pdf->Output('','S');
        // I also use  $pdf->Output('S');
        Storage::put('docs/kek.pdf', $pdf);    
        return $pdf;  
    }

But it isn’t works, because Output() anyway returns to $pdf only object. Have you any idea?)

Advertisement

Answer

You have to save the string output that fPDF creates before you can do something with it.

Change:

$pdf->Output('S');
Storage::put('docs/kek.pdf', $pdf);    

to:

$theString = $pdf->Output('S');
Storage::put('docs/kek.pdf', $theString);  
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement