Skip to content

Commit ab58800

Browse files
committed
update examples and documentation
1 parent ac46dfe commit ab58800

51 files changed

Lines changed: 4074 additions & 2779 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,28 @@ If this library saves you time, please consider [supporting its development via
1414

1515
---
1616

17+
## Contents
18+
19+
- [Overview](#overview)
20+
- [Description](#description)
21+
- [For TCPDF Users](#for-tcpdf-users)
22+
- [Features](#features)
23+
- [Requirements](#requirements)
24+
- [Installation](#installation)
25+
- [Font Setup](#font-setup)
26+
- [Quick Start](#quick-start)
27+
- [Digital Signatures](#digital-signatures)
28+
- [PDF/X Conformance](#pdfx-conformance)
29+
- [PDF/UA Accessibility](#pdfua-accessibility)
30+
- [Development](#development)
31+
- [Packaging](#packaging)
32+
- [Contributing](#contributing)
33+
- [Third-Party Fonts](#third-party-fonts)
34+
- [ICC Profile](#icc-profile)
35+
- [Contact](#contact)
36+
37+
---
38+
1739
## Overview
1840

1941
`tc-lib-pdf` is a pure-PHP library for dynamically generating PDF documents.
@@ -48,6 +70,16 @@ The library is particularly well suited to backend-driven document workflows suc
4870

4971
Because it is part of the broader `tc-lib-*` ecosystem, `tc-lib-pdf` can coordinate fonts, images, page geometry, graphics primitives, and optional features such as barcodes and encryption through dedicated companion packages. That modular design makes the project easier to evolve over time while still delivering the all-in-one capabilities PHP developers expect from a serious PDF engine.
5072

73+
## For TCPDF Users
74+
75+
If you already know TCPDF, `tc-lib-pdf` will feel familiar in purpose but it is not positioned as a drop-in replacement.
76+
77+
- The codebase is split across focused Composer packages instead of a single monolithic distribution.
78+
- The API surface is more strongly typed and organized around companion services such as fonts, pages, graphics, and images.
79+
- Setup is Composer-first, which means asset preparation such as font generation is part of project bootstrap rather than an implicit bundled step.
80+
81+
The fastest way to evaluate the library is to follow the installation and font setup steps below, then compare the runnable examples in [examples/index.md](examples/index.md) with the equivalent workflows you already maintain in TCPDF.
82+
5183
## Features
5284

5385
### Text & Fonts
@@ -104,14 +136,26 @@ Because it is part of the broader `tc-lib-*` ecosystem, `tc-lib-pdf` can coordin
104136
## Requirements
105137

106138
- **PHP 8.1** or later
139+
- Required PHP extensions: `date`, `pcre` (enforced by Composer)
107140
- Composer
108141

109142
Optional PHP extensions for extended functionality: `gd`, `zlib`.
110143

144+
Feature-specific prerequisites:
145+
146+
- Digital signatures, timestamps, and LTV workflows require signing certificates/keys and any external TSA or revocation endpoints your configuration references.
147+
- `make preflight` depends on external validation tools when you want standards validation beyond the built-in sample generation.
148+
111149
---
112150

113151
## Installation
114152

153+
For a clean first run:
154+
155+
1. Install the package with Composer.
156+
2. Generate the companion font files.
157+
3. Run the minimal script using the generated `K_PATH_FONTS` path.
158+
115159
```bash
116160
composer require tecnickcom/tc-lib-pdf
117161
```
@@ -132,7 +176,7 @@ Or add to your `composer.json`:
132176

133177
When you install `tc-lib-pdf` as a dependency in your project (via `composer require` or `composer install`), the fonts from the companion package [`tc-lib-pdf-font`](https://github.com/tecnickcom/tc-lib-pdf-font) must be generated before they can be used.
134178

135-
Since Composer does not execute dependency scripts during installation, you need to add the font generation step to your **consuming project's** `composer.json` file:
179+
Composer does not execute scripts declared by dependencies, so you need to add the font generation step to your **consuming project's** `composer.json` file:
136180

137181
```json
138182
{
@@ -185,12 +229,14 @@ This avoids regenerating fonts on every dependency reinstall and lets multiple d
185229

186230
## Quick Start
187231

232+
The following example assumes the script lives in your project root. If you place it elsewhere, adjust the `autoload.php` and `K_PATH_FONTS` paths accordingly.
233+
188234
```php
189235
<?php
190236

191-
require(__DIR__ . '/../vendor/autoload.php');
237+
require(__DIR__ . '/vendor/autoload.php');
192238

193-
\define('K_PATH_FONTS', \realpath(__DIR__ . '/../vendor/tecnickcom/tc-lib-pdf-font/target/fonts'));
239+
\define('K_PATH_FONTS', \realpath(__DIR__ . '/vendor/tecnickcom/tc-lib-pdf-font/target/fonts'));
194240

195241
$pdf = new \Com\Tecnick\Pdf\Tcpdf();
196242

@@ -209,8 +255,10 @@ $rawpdf = $pdf->getOutPDFString();
209255
$pdf->renderPDF($rawpdf);
210256
```
211257

258+
`getOutPDFString()` returns the raw PDF bytes. `renderPDF()` streams those bytes to the browser; if you need file storage or an email attachment, keep the returned string and write or hand it off yourself.
259+
212260
For more complete examples — including invoices, images, barcodes, HTML tables, dedicated HTML selector/form/table showcases, PDF/X, and PDF/UA — see the [examples](examples) directory.
213-
Annotation-focused runnable example: [examples/027_example_annotations.php](examples/027_example_annotations.php).
261+
Annotation-focused runnable example: [examples/E027_annotations.php](examples/E027_annotations.php).
214262

215263
To run the bundled examples locally:
216264

@@ -221,6 +269,11 @@ make server # start a local PHP server
221269

222270
Then open <http://localhost:8971/index.php>.
223271

272+
If the minimal example fails on first run, verify these two points first:
273+
274+
- `K_PATH_FONTS` resolves to an existing generated font directory.
275+
- The companion fonts were generated after `composer install` or `composer update`.
276+
224277
---
225278

226279
## Digital Signatures
@@ -229,9 +282,9 @@ Then open <http://localhost:8971/index.php>.
229282

230283
Signature-focused runnable examples:
231284

232-
- [examples/007_example_signature_basic.php](examples/007_example_signature_basic.php) : basic detached CMS signature with visible signature fields.
233-
- [examples/008_example_signature_timestamp.php](examples/008_example_signature_timestamp.php) : detached CMS signature with RFC 3161 TSA timestamp configuration.
234-
- [examples/009_example_signature_ltv.php](examples/009_example_signature_ltv.php) : detached CMS signature with LTV validation material embedding.
285+
- [examples/E007_signature_basic.php](examples/E007_signature_basic.php) : basic detached CMS signature with visible signature fields.
286+
- [examples/E008_signature_timestamp.php](examples/E008_signature_timestamp.php) : detached CMS signature with RFC 3161 TSA timestamp configuration.
287+
- [examples/E009_signature_ltv.php](examples/E009_signature_ltv.php) : detached CMS signature with LTV validation material embedding.
235288

236289
### Basic signature
237290

@@ -328,7 +381,7 @@ Each variant automatically applies the appropriate conformance constraints:
328381

329382
All PDF/X modes suppress encryption and JavaScript (not permitted by the ISO 15930 standard).
330383

331-
Runnable examples: [examples/010_example_pdfx.php](examples/010_example_pdfx.php) through [examples/014_example_pdfx5.php](examples/014_example_pdfx5.php).
384+
Runnable examples: [examples/E010_pdfx.php](examples/E010_pdfx.php) through [examples/E014_pdfx5.php](examples/E014_pdfx5.php).
332385

333386
---
334387

@@ -362,7 +415,7 @@ To provide the document language explicitly:
362415
$pdf->setDocInfo(['a_meta_language' => 'de-DE']);
363416
```
364417

365-
Runnable examples: [examples/015_example_pdfua.php](examples/015_example_pdfua.php) through [examples/017_example_pdfua2.php](examples/017_example_pdfua2.php).
418+
Runnable examples: [examples/E015_pdfua.php](examples/E015_pdfua.php) through [examples/E017_pdfua2.php](examples/E017_pdfua2.php).
366419

367420
---
368421

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.10.3
1+
8.10.4

0 commit comments

Comments
 (0)