Skip to content

Examples Overview

Explore practical, copy-paste-ready examples that demonstrate how to use TCPDF-Next in real-world scenarios. Every example uses the fluent API pattern and targets PHP 8.5+.

Getting Started

Make sure TCPDF-Next is installed before running any example:

bash
composer require tcpdf-next/tcpdf-next

All examples assume the following base import:

php
use TcpdfNext\Document;

Basic Examples Beginner

Fundamental PDF operations -- perfect for your first TCPDF-Next project.

ExampleDescription
Hello WorldCreate your very first PDF with a single fluent chain
Text FormattingFonts, sizes, styles, colors, and alignment via the Alignment enum
TablesRender HTML tables with writeHtml(), styled headers, colspan / rowspan
ImagesEmbed JPEG, PNG, and SVG images with positioning and scaling
Multi-Page DocumentsAuto page breaks, manual pages, headers, footers, and page numbering

Intermediate Examples Intermediate

Build on the basics with headers, watermarks, HTML conversion, and barcodes.

ExampleDescription
Headers & FootersCustom repeating headers and footers via callbacks
WatermarksText and image watermarks with transparency
Table of ContentsAuto-generated TOC with bookmarks
HTML to PDFConvert rich HTML/CSS content to PDF
Barcodes & QR CodesGenerate 1D and 2D barcodes

Advanced Examples Advanced

Production-grade features: digital signatures, encryption, archival compliance, and interactive forms.

ExampleDescription
Digital SignaturePAdES B-B signing with PKCS#12 certificates
PAdES B-LTA WorkflowLong-term validation with timestamping
PDF/A-4 ArchivalISO 19005-4 compliant archival documents
AES-256 EncryptionPassword-based AES-256 document encryption
Form FieldsInteractive text fields, checkboxes, and dropdowns

Laravel Examples Laravel

Integrate TCPDF-Next into your Laravel application with facades, responses, and queued jobs.

ExampleDescription
Invoice GenerationProfessional invoice PDF via the Pdf facade
Report with ChartsEmbed chart images into a multi-page report
Batch PDF QueueQueue-based batch generation with GeneratePdfJob
Signed ContractGenerate and digitally sign a contract

Fluent API

Every example on this site uses TCPDF-Next's fluent method-chaining API. All setter and action methods return static, so you can write expressive, readable PDF generation code:

php
Document::create()
    ->setTitle('My Document')
    ->addPage()
    ->setFont('helvetica', size: 14)
    ->cell(0, 10, 'Hello World')
    ->save('output.pdf');

Released under the LGPL-3.0-or-later License.