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:
composer require tcpdf-next/tcpdf-nextAll examples assume the following base import:
use TcpdfNext\Document;Basic Examples Beginner
Fundamental PDF operations -- perfect for your first TCPDF-Next project.
| Example | Description |
|---|---|
| Hello World | Create your very first PDF with a single fluent chain |
| Text Formatting | Fonts, sizes, styles, colors, and alignment via the Alignment enum |
| Tables | Render HTML tables with writeHtml(), styled headers, colspan / rowspan |
| Images | Embed JPEG, PNG, and SVG images with positioning and scaling |
| Multi-Page Documents | Auto page breaks, manual pages, headers, footers, and page numbering |
Intermediate Examples Intermediate
Build on the basics with headers, watermarks, HTML conversion, and barcodes.
| Example | Description |
|---|---|
| Headers & Footers | Custom repeating headers and footers via callbacks |
| Watermarks | Text and image watermarks with transparency |
| Table of Contents | Auto-generated TOC with bookmarks |
| HTML to PDF | Convert rich HTML/CSS content to PDF |
| Barcodes & QR Codes | Generate 1D and 2D barcodes |
Advanced Examples Advanced
Production-grade features: digital signatures, encryption, archival compliance, and interactive forms.
| Example | Description |
|---|---|
| Digital Signature | PAdES B-B signing with PKCS#12 certificates |
| PAdES B-LTA Workflow | Long-term validation with timestamping |
| PDF/A-4 Archival | ISO 19005-4 compliant archival documents |
| AES-256 Encryption | Password-based AES-256 document encryption |
| Form Fields | Interactive text fields, checkboxes, and dropdowns |
Laravel Examples Laravel
Integrate TCPDF-Next into your Laravel application with facades, responses, and queued jobs.
| Example | Description |
|---|---|
| Invoice Generation | Professional invoice PDF via the Pdf facade |
| Report with Charts | Embed chart images into a multi-page report |
| Batch PDF Queue | Queue-based batch generation with GeneratePdfJob |
| Signed Contract | Generate 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:
Document::create()
->setTitle('My Document')
->addPage()
->setFont('helvetica', size: 14)
->cell(0, 10, 'Hello World')
->save('output.pdf');