PHP library to define and render PDF pages.
💖 Part of the tc-lib-pdf / TCPDF ecosystem (100M+ installs). Sponsor its maintenance →
tc-lib-pdf-page keeps the page stack of a PDF document and outputs the page
tree, the page objects and the content streams.
| Namespace | \Com\Tecnick\Pdf\Page |
| Author | Nicola Asuni info@tecnick.com |
| License | GNU LGPL v3 - see LICENSE |
| API docs | https://tcpdf.org/docs/srcdoc/tc-lib-pdf-page |
| Packagist | https://packagist.org/packages/tecnickcom/tc-lib-pdf-page |
- Named page formats (ISO, ANSI, JIS, envelopes, photographic and other series) and custom sizes
- Portrait, landscape and size-derived orientation
- Conversion between points, millimeters, centimeters and inches
- MediaBox, CropBox, BleedBox, TrimBox and ArtBox, each with its BoxColorInfo guidelines
- Page, header, content and footer margins, with mirrored gutters in booklet mode
- Writable regions: equal columns, or rectangles computed around no-write areas
- Add, clone, move, delete and select pages, grouped for per-group numbering
- Page content stack with marks, and
~#PN/~#PTpage number aliases - Annotation references, rotation, preferred zoom and page transitions
- Per-page transparency group policy, disabled in PDF/A mode
- PDF output with optional Flate compression and encryption
Unit,Orientation,PageBoxType,PageLayout,PageDisplayMode,TransparencyGroupMode
- PHP 8.2 or later
- Extension:
zlib - Composer
composer require tecnickcom/tc-lib-pdf-page<?php
require_once __DIR__ . '/vendor/autoload.php';
$page = new \Com\Tecnick\Pdf\Page\Page(
'mm',
new \Com\Tecnick\Color\Pdf(),
new \Com\Tecnick\Pdf\Encrypt\Encrypt(false),
);
$page->add([
'format' => 'A4',
'orientation' => 'P',
'margin' => ['PL' => 20, 'PR' => 20, 'PT' => 15, 'PB' => 15],
'columns' => 2,
]);
$page->addContent('BT /F1 12 Tf 100 700 Td (Page ~#PN of ~#PT) Tj ET');
$pon = 0;
$pdfpages = $page->getPdfPages($pon);add() returns the sanitized page data, including the page boxes in points, the
normalized margins and the writable regions. getPdfPages() returns the PDF
objects of the whole stack and advances $pon past the last object number used.
make deps
make help
make qamake rpm
make debFor system packages, bootstrap with:
require_once '/usr/share/php/Com/Tecnick/Pdf/Page/autoload.php';Contributions are welcome. Please review CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.