How to generate fpdf?

笑着哭i 提交于 2019-12-24 08:48:36

问题


I am getting error 'Class "Fpdf" not found'.

use Fpdf;
Fpdf::AddPage(); 
Fpdf::SetFont('Courier', 'B', 18); 
Fpdf::Cell(50, 25, 'Hello World!'); 
Fpdf::Output();

回答1:


  1. Install using Composer
    composer require codedge/laravel-fpdf
  2. Add the following lines to your config/app.php

    'providers' => [
        // ...
    
        Codedge\Fpdf\FpdfServiceProvider::class,
    ],
    
    'aliases' => [
        // ...
    
        'Fpdf' => Codedge\Fpdf\Facades\Fpdf::class,
    ]
    
  3. Use it (omit use Fpdf):

    Fpdf::AddPage();
    Fpdf::SetFont('Courier', 'B', 18);
    Fpdf::Cell(50, 25, 'Hello World!');
    Fpdf::Output();
    

    or

    $fpdf = new Codedge\Fpdf\Fpdf\Fpdf();
    $fpdf->AddPage();
    $fpdf->SetFont('Courier', 'B', 18);
    $fpdf->Cell(50, 25, 'Hello World!');
    $fpdf->Output();
    


来源:https://stackoverflow.com/questions/47348486/how-to-generate-fpdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!