Architecture Deep Dive
TCPDF-Next is organized into 26 modules across 4 packages, with 213 PHP source files total.
Project Statistics
| Metric | Core | Laravel | Artisan | Pro | Total |
|---|---|---|---|---|---|
| PHP source files | 148 | 4 | 17 | 47 | 213 |
| Modules | 16 | 1 | 2 | 7 | 26 |
| Tests | 908 | — | 7 classes | — | 908+ |
| Assertions | 28,881 | — | — | — | 28,881+ |
| PHPStan level | 8 | 8 | 8 | 8 | 8 |
Namespace Map
Core (yeeefang/tcpdf-next)
Yeeefang\TcpdfNext\
├── Core\ # Document, ObjectRegistry, TransactionManager, CrossReferenceStream
│ └── Concerns\ # 12 composable traits (HasMetadata, HasPages, ...)
├── Contracts\ # PdfDocumentInterface, SignerInterface, HsmSignerInterface, enums
├── ValueObjects\ # PageSize, Dimension, Margin, Position, Unit
├── Support\ # BinaryBuffer
├── Content\ # TextRenderer, JavaScriptManager, Hyphenator
│ └── Hyphenation\ # HyphenationPatterns
├── Typography\ # FontManager, TrueTypeParser, Type1Parser, FontSubsetter, BiDiResolver
├── Graphics\ # DrawingEngine, TransformEngine, Color, ImageLoader, SvgParser
├── Layout\ # HeaderFooter, ColumnLayout, BookletLayout, PageManager
├── Html\ # HtmlParser, TableParser, CssRule
├── Form\ # FormFieldManager, FormFlattener
├── Barcode\ # Barcode1D, Barcode2D, BarcodeRenderer
│ ├── QrCode\ # QrEncoder
│ ├── DataMatrix\ # DataMatrixEncoder
│ └── Pdf417\ # Pdf417Encoder
├── Navigation\ # BookmarkManager, LinkManager, TocBuilder, AnnotationManager
├── Accessibility\ # StructureTree, RoleMap, StructureElement
├── Security\ # Encryption + Signatures
│ ├── Encryption\ # Aes256Encryptor, SaslPrep
│ ├── Signature\ # DigitalSigner, PadesOrchestrator, CertificateInfo, SignatureAppearance
│ └── Timestamp\ # TsaClient
└── Writer\ # PdfWriter, Linearizer, ViewerPreferences, data classesArtisan (yeeefang/tcpdf-nextartisan)
Yeeefang\TcpdfNext\
├── Artisan\ # ChromeHtmlRenderer, BrowserPool, ChromeRendererConfig
│ └── Exception\ # ChromeNotAvailableException, ChromeRenderException, PdfParseException
└── Parser\ # PdfTokenizer, CrossRefParser, PdfReader, StreamDecoder, ResourceCollectorLaravel (yeeefang/tcpdf-nextlaravel)
Yeeefang\TcpdfNext\Laravel\
├── TcpdfServiceProvider
├── Facades\Pdf
├── Http\PdfResponse
└── Jobs\GeneratePdfJobPro (yeeefang/tcpdf-nextpro)
Yeeefang\TcpdfNext\
├── Archive\ # PdfAManager, PdfAVersion, XmpMetadata, OutputIntent
├── Barcode\ # Specialty barcodes
│ ├── MicroQr\ # MicroQrEncoder
│ ├── DotCode\ # DotCodeEncoder
│ ├── HanXin\ # HanXinEncoder
│ ├── JabCode\ # JabCodeEncoder (LDPC, interleaver, matrix)
│ ├── Gs1\ # Gs1DataParser
│ └── Imb\ # ImbEncoder
├── Security\
│ ├── Ltv\ # LtvManager, DssBuilder, OcspClient, CrlFetcher, CertificateChainValidator
│ ├── Signature\Hsm\ # Pkcs11Signer, OpenSslEngineSigner
│ ├── Timestamp\ # DocumentTimestamp
│ ├── Asn1\ # CertificateParser, AlgorithmIdentifier
│ └── CertificateTransparency\ # CtValidationResult
└── Writer\ # IncrementalUpdateWriterLazy Initialization
The Document class instantiates only essential sub-engines in the constructor:
Always initialized: DocumentData, PdfWriter, FontManager, DrawingEngine, TransformEngine, TextRenderer, HeaderFooter, ColumnLayout, BookmarkManager, LinkManager, TocBuilder, AnnotationManager, PageManager, FontMetrics
Lazy (null until first use): FormFieldManager, LayerManager, TemplateManager, TransactionManager, BookletLayout, FileAttachment, JavaScriptManager, SvgParser, EpsParser, StructureTree, SpotColorManager, ImageLoader, BiDiResolver
This keeps the base memory footprint small for simple documents while providing full functionality when needed.
Extension Integration
The Core package detects extensions at runtime via class_exists():
// Artisan detection
$rendererClass = 'Yeeefang\\TcpdfNext\\Artisan\\ChromeHtmlRenderer';
if (!class_exists($rendererClass)) {
throw new \RuntimeException(
'Chrome renderer requires yeeefang/tcpdf-nextartisan.'
);
}This means:
- Core has zero hard dependencies on Artisan, Laravel, or Pro
- Extensions are autoloaded by Composer — just
composer requireand they work - The Laravel ServiceProvider auto-detects Artisan and Pro, configuring bindings accordingly