承接 aryatama045/laravel-fpdf 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aryatama045/laravel-fpdf

Composer 安装命令:

composer require aryatama045/laravel-fpdf

包简介

Laravel package to include Fpdf. It ships with Fpdf 1.84.

README 文档

README

install

1) Composer

composer require aryatama045/laravel-fpdf

2) Optional: Laravel 5.4 and below

// config/app.php

'providers' => [
  // ...
  Aryatama045\Fpdf\FpdfServiceProvider::class,
],

'aliases' => [
  // ...
  'Fpdf' => Aryatama045\Fpdf\Facades\Fpdf::class,
],

Usage

(Method 1) Facade

use App\Http\Controllers\Controller;
use Aryatama045\Fpdf\Facades\Fpdf;

class MyController extends Controller
{
    public function index()
    {
        Fpdf::AddPage();
        Fpdf::SetFont('Courier', 'B', 18);
        Fpdf::Cell(50, 25, 'Hello World!');
        Fpdf::Output('I', "MyPdf.pdf", true);

        exit;
    }
}

(Method 2) Extends class

create your pdf class

namespace App\Pdf;

use Aryatama045\Fpdf\Fpdf;

class MyPdf extends Fpdf
{
    private $data;

    public function __construct($data)
    {
        $this->data = $data;
        parent::__construct('P', 'mm', 'A4');
        $this->SetA4();
        $this->SetTitle('My pdf title', true);
        $this->SetAuthor('Aryatama', true);
        $this->AddPage('L');
        $this->Body();
    }

    public function Header()
    {
        // fixed all pages
    }

    public function Body()
    {
        $this->SetFont('Arial', 'B', '24');
        $this->Cell(50, 25, $this->data->title);

        $this->SetFont('Arial', '', '14');
        $this->Cell(50, 25, $this->data->content);
    }

    public function Footer()
    {
        // fixed all pages
    }
}

In your controll

use App\Http\Controllers\Controller;
use App\Pdf\MyPdf;

class MyController extends Controller
{
    public function index()
    {
        $data = MyModel::all();

        $myPdf = new MyPdf($data);

        $myPdf->Output('I', "MyPdf.pdf", true);

        exit;
    }
}

FPDF official docs

http://www.fpdf.org

统计信息

  • 总下载量: 56
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固