Skip to content

Bắt đầu

TCPDF-Next là thư viện PHP 8.5+ hiện đại dùng để tạo tài liệu PDF 2.0. Hướng dẫn này giúp bạn tạo PDF đầu tiên trong 5 phút.

Yêu cầu hệ thống

Yêu cầuTối thiểu
PHP8.5+
Extensionopenssl, zlib, mbstring, gd, curl, intl
Composer2.x

Cài đặt

bash
composer require yeeefang/tcpdf-next

Lệnh này cài đặt package Core với toàn bộ 220+ file mã nguồn.

Package tùy chọn

bash
# Chrome CDP HTML renderer (CSS3 chính xác đến từng pixel)
composer require yeeefang/tcpdf-next-artisan

# Tích hợp framework
composer require yeeefang/tcpdf-next-laravel        # Laravel 12
composer require yeeefang/tcpdf-next-symfony         # Symfony 7
composer require yeeefang/tcpdf-next-codeigniter     # CodeIgniter 4

# Adapter tương thích ngược TCPDF 6.2.13
composer require yeeefang/tcpdf-next-adaptation

# Tính năng doanh nghiệp (giấy phép thương mại)
composer require yeeefang/tcpdf-next-pro

PDF đầu tiên

php
<?php

require 'vendor/autoload.php';

use Yeeefang\TcpdfNext\Core\Document;

$pdf = Document::createStandalone()
    ->setTitle('My First PDF')
    ->setAuthor('TCPDF-Next')
    ->addPage()
    ->setFont('Helvetica', '', 16)
    ->cell(0, 10, 'Hello, PDF 2.0!')
    ->ln()
    ->setFont('Helvetica', '', 12)
    ->cell(0, 10, 'Generated with TCPDF-Next')
    ->save('hello.pdf');

echo "PDF saved to hello.pdf\n";

Chạy thử:

bash
php hello.php

Luồng tạo PDF

Bước tiếp theo

Phân phối theo giấy phép LGPL-3.0-or-later.