You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add fileOptions to Tcpdf constructor, fix inline HTML wrap continuation, and sync fileid from encryption object
- Tcpdf/initClassObjects: add optional $fileOptions (TFileOptions) parameter to
configure ObjFile; remote URL loading is disabled by default and requires an
explicit allowedHosts whitelist (security hardening)
- fix some issues with HTML inline layout
- add Text Unicode Substitution
- fixed issue with encryption
- new example E045_encryption_and_permissions.php
Co-authored-by: Copilot <copilot@github.com>
Copy file name to clipboardExpand all lines: README.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ If this library saves you time, please consider [supporting its development via
24
24
-[Installation](#installation)
25
25
-[Font Setup](#font-setup)
26
26
-[Quick Start](#quick-start)
27
+
-[Remote Resources and fileOptions](#remote-resources-and-fileoptions)
27
28
-[Digital Signatures](#digital-signatures)
28
29
-[PDF/X Conformance](#pdfx-conformance)
29
30
-[PDF/UA Accessibility](#pdfua-accessibility)
@@ -276,6 +277,57 @@ If the minimal example fails on first run, verify these two points first:
276
277
277
278
---
278
279
280
+
## Remote Resources and `fileOptions`
281
+
282
+
By default `tc-lib-pdf`**does not fetch any remote URLs**. Images, fonts, and SVG files referenced by HTTP or HTTPS are blocked unless you explicitly allow the originating hosts. Local file paths are never restricted.
283
+
284
+
Remote access is controlled by the optional `$fileOptions` array passed as the last argument to the `Tcpdf` constructor (and forwarded to `initClassObjects()`).
Only the listed host names are permitted. Any attempt to load a resource from an unlisted host is silently blocked. Supply an explicit allowlist rather than a wildcard to limit the attack surface when user-supplied URLs might reach this code path.
298
+
299
+
### All `fileOptions` keys
300
+
301
+
| Key | Type | Default | Description |
302
+
|-----|------|---------|-------------|
303
+
|`allowedHosts`|`string[]`|`[]` (none) | Host names the library may fetch over HTTP/HTTPS. Remote loading is disabled when this list is empty. |
304
+
|`maxRemoteSize`|`int`|`52428800` (50 MiB) | Maximum bytes accepted for a single remote download. Requests exceeding this limit are aborted. |
305
+
|`curlopts`|`array<int, bool\|int\|string>`|`[]`| Per-request cURL options (keyed by `CURLOPT_*` constants) merged on top of the built-in defaults. |
306
+
|`defaultCurlOpts`|`array<int, bool\|int\|string>`|`null`| Replaces the built-in default cURL option set entirely. Omit this key to keep the safe defaults. |
307
+
|`fixedCurlOpts`|`array<int, bool\|int\|string>`|`null`| cURL options that are always enforced and cannot be overridden by `curlopts` — useful for pinning TLS settings in locked-down environments. |
308
+
309
+
### Example: pinning TLS and setting a short timeout
310
+
311
+
```php
312
+
$pdf = new \Com\Tecnick\Pdf\Tcpdf(
313
+
unit: 'mm',
314
+
fileOptions: [
315
+
'allowedHosts' => ['cdn.example.com'],
316
+
'maxRemoteSize' => 10 * 1024 * 1024, // 10 MiB
317
+
'curlopts' => [
318
+
CURLOPT_TIMEOUT => 10,
319
+
CURLOPT_CONNECTTIMEOUT => 5,
320
+
],
321
+
'fixedCurlOpts' => [
322
+
CURLOPT_SSL_VERIFYPEER => true,
323
+
CURLOPT_SSL_VERIFYHOST => 2,
324
+
],
325
+
],
326
+
);
327
+
```
328
+
329
+
---
330
+
279
331
## Digital Signatures
280
332
281
333
`tc-lib-pdf` supports detached CMS (PKCS#7) signatures with optional RFC 3161 timestamps and LTV (Long-Term Validation) material, all embedded in a single PDF revision.
Copy file name to clipboardExpand all lines: examples/E031_html_features.php
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -350,6 +350,19 @@
350
350
351
351
// ----------
352
352
353
+
// HTML E-L
354
+
355
+
$html_05L = '<p>Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliett Kilo. Lima Mike November Oscar Papa Quebec Romeo (<em>Sierra-Tango</em>) Uniform Victor Whiskey (<em>Xray-Yankee</em>). Zulu. Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliett Kilo. Lima Mike November Oscar Papa Quebec Romeo (<em>Sierra-Tango</em>) Uniform Victor Whiskey (<em>Xray-Yankee</em>). Zulu. Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India Juliett Kilo. Lima Mike November Oscar Papa Quebec Romeo (<em>Sierra-Tango</em>) Uniform Victor Whiskey (<em>Xray-Yankee</em>). Zulu.</p>';
0 commit comments