Document API
The Document class (TcpdfNext\Core\Document) is the primary entry point for creating PDF documents. It composes 12 traits, each contributing a group of related methods. All mutating methods return static for fluent chaining.
use TcpdfNext\Core\Document;
$pdf = Document::create()
->setTitle('Invoice')
->addPage()
->setFont('Helvetica', size: 12)
->cell(width: 0, height: 10, text: 'Hello World')
->save('/output/invoice.pdf');HasMetadata
Methods for setting document-level metadata (Title, Author, Subject, Keywords, Creator).
HasPages
Methods for adding, deleting, moving, and configuring pages.
HasTypography
Methods for font selection, sizing, spacing, and string measurement.
HasColors
Methods for setting draw, fill, and text colors with optional alpha transparency.
HasTextOutput
Methods for rendering text content onto the page.
HasDrawing
Methods for drawing lines, shapes, and arrows.
HasTransforms
Methods for coordinate system transformations (saved as a stack).
HasLayout
Methods for headers, footers, columns, and booklet mode.
HasNavigation
Methods for bookmarks, table of contents, links, annotations, and file attachments.
HasInteractive
Methods for AcroForm form fields and JavaScript.
HasSecurity
Methods for encryption and digital signatures.
HasOutput
Methods for rendering the final PDF.
See Also
- API Overview -- All packages at a glance
- Enums Reference -- Orientation, Alignment, OutputDestination, and more
- Interfaces Reference -- Contracts the Document class implements
- Value Objects API -- PageSize, Margin, Position, Dimension, Unit