What the library provides, grouped by area, with a link to the guide or the runnable example that covers each item. For how this compares with the other PHP PDF tools, see /comparison/ .
Table of contents
Pages and Layout
- Named page formats: ISO, ANSI, JIS, envelope, photographic and other series, plus arbitrary custom sizes. See /examples/E004_page_formats/ .
- Portrait, landscape, and orientation derived from the requested size.
- Units of points, millimetres, centimetres, and inches, selected per document.
- The five page boxes (MediaBox, CropBox, BleedBox, TrimBox, ArtBox), each with its BoxColorInfo guidelines, and
omitPageBox()/keepPageBox()for the ISO 15930 rule that a page declares a TrimBox or an ArtBox but not both. See /examples/E048_page_boxes_prepress/ . - Page, header, content, and footer margins, with mirrored gutters in booklet mode.
- Writable regions: equal columns, or rectangles computed around reserved areas that text and HTML flow must avoid. See /examples/E080_no_write_regions/ .
- Page stack operations: add, clone, move, delete, and select, with page groups for per-group numbering. See /examples/E054_page_groups_numbering/ and /examples/E055_page_reorder_booklet/ .
- Page number aliases (
~#PN,~#PT) resolved at output time. - Page rotation, preferred zoom, and page transitions.
- Headers, footers, and default page content. See /examples/E005_header_footer/ .
- Per-page transparency group control, with the group omitted on fully opaque pages.
Text and Typography
- Text cells with horizontal alignment (left, centre, right, justified) and vertical alignment (top, centre, bottom, ascent, baseline, descent). See /examples/E023_cell_alignment/ .
- Overflow fit modes: truncate, stretch, or shrink the font to the cell. See /examples/E074_text_cell_fit_modes/ .
- Line wrapping and line height control. See /examples/E083_text_line_wrap/ .
- Hyphenation, including custom dictionaries. See /examples/E028_text_hyphenation/ and /examples/E064_custom_hyphenation_dictionary/ .
- Font stretching and character spacing, combinable in one matrix. See /examples/E079_font_stretch_spacing_matrix/ .
- Text rendering modes: fill, stroke, fill and stroke, invisible, and the clipping variants. See /examples/E026_text_rendering_modes/ .
- Measured output:
getTextCell()returns the operators plus the bounding box and metrics, so text can be positioned from what it actually measures. See /examples/E071_gettextcell_bbox_metrics/ . - Absolute positioning alongside flowed content. See /examples/E076_absolute_position/ .
- Cell borders and background fills. See /examples/E022_cell_borders/ .
Multilingual Text
- Unicode 17 character data, generated from UCD 17.0.0.
- Unicode Bidirectional Algorithm (UAX #9), verified against the official
BidiCharacterTest.txtandBidiTest.txtconformance suites. See /examples/E062_bidi_mixed_rtl_ltr/ . - Forced paragraph direction (auto, right-to-left, left-to-right) per text call.
- Arabic shaping driven by the Joining_Type property, with lam-alef and allah ligatures placed so combining marks keep following their base. See /examples/E003_rtl_languages/ .
- Devanagari left-positional matra reordering and Hangul Jamo composition into precomposed syllables.
- Coverage checks across scripts. See /examples/E046_pangrams/ .
Two boundaries are worth knowing. Shaping is codepoint-level substitution rather than OpenType Layout: there is no GSUB or GPOS processing, so the cursive scripts other than Arabic (Syriac, N’Ko, Mandaic, Adlam) are drawn unshaped, and Indic shaping stops at matra reordering. In the bidirectional algorithm, rule L3 (combining marks displayed in a different order) is not implemented, and the paragraph separator is appended to the paragraph output rather than being reset by L1 and reversed by L2.
Fonts
- Font types: TrueType Unicode, OpenType Unicode v1, TrueType, OpenType v1, Type1, CID-0, and the PDF core fonts.
- Full embedding, subsetting, and non-embedded use. See /examples/E068_font_subset/ .
- Composite (Type0) fonts with
Identity-Hencoding and a/ToUnicodeCMap generated for the glyphs in use, so text stays searchable and extractable. - Supplementary-plane characters (emoji, CJK extensions, mathematical alphanumerics) from fonts converted with the full Unicode cmap subtable.
- Custom font import through the bundled conversion utility. See /examples/E072_import_new_font/ .
- Fallback fonts for missing glyphs. See /examples/E052_custom_fonts_fallback/ .
- Font inspection tooling. See /examples/E002_font_dump/ .
Full guide: /docs/fonts/ .
HTML and CSS
addHTMLCell()renders markup into a placed block, with style inheritance.- Cascade and source order, shorthand expansion and normalization, and the
inheritkeyword including its shorthand forms. - Selectors: type, class and id, descendant, child, adjacent and general sibling combinators (
+,~), attribute selectors, and a pseudo-class subset including:empty. - Pseudo-elements
::beforeand::afterwith text content. - Box model, floats, clearance, and positioning, including
inline-block,fieldsetandlegend. - Paged media:
orphans,widows, and page break control, plus the print media type. - A global base stylesheet applied to every block through
setGlobalCSS(). - Spot colours addressed from CSS, for prepress work driven by markup.
- Typography properties including
font-size-adjust,font-variant,quotes, andoverflow-wrap. - The categories are enumerated, and rendered by the engine itself, in /examples/E073_css_supported_categories/ and /examples/E031_html_features/ .
- Tables with the full structure tags (
caption,colgroup,col,thead,tfoot), spanning cells, repeated headers across pages, border models, and pixel units. See /examples/E043_html_tables/ and /examples/E077_html_table_header_px_unit/ . - Ordered, unordered, and nested lists. See /examples/E032_html_lists/ .
- Form controls in markup, with labels, field flags, and select precedence, mapped to AcroForm widgets and their interactive states. See /examples/E042_html_form/ .
- Content spanning page breaks, line height control, and interaction with page margins. See /examples/E018_html_page_span/ , /examples/E069_html_line_height/ , and /examples/E078_htmlcell_page_margins/ .
Vector Graphics
- Primitives: points, lines, rectangles, Bezier curves, ellipses, circles, elliptical arcs, pie sectors, polygons, regular and star polygons, rounded rectangles, and arrows. See /examples/E036_graphic_methods/ .
- Crop marks and registration marks for prepress. See /examples/E035_registration_marks/ .
- A style stack carrying line width, cap, join, mitre limit, dash pattern, and colours.
- All 16 PDF blend modes, constant alpha, and overprint through
ExtGStateobjects. See /examples/E025_transparency/ . - Axial and radial shadings with multiple stops and per-stop opacity, Coons patch meshes, and colour registration bars. See /examples/E034_color_gradient_mesh/ .
- Scaling, rotation, mirroring, reflection, translation, and skewing, with a transformation stack. See /examples/E033_geometric_transformations/ .
- Path painting and clipping operators exposed as typed cases.
- Reusable Form XObject templates. See /examples/E029_xobject_template/ .
- Optional content groups with visibility control. See /examples/E041_layers_visibility/ .
Colour
- Models: RGB and RGBA, HSL and HSLA, CMYK, CIE Lab, and grayscale. See /examples/E024_colors/ .
- Spot colours (Separation) with DeviceCMYK or Lab alternate spaces, plus overprint and proofing workflows. See /examples/E053_spot_overprint_proof/ .
- CSS colour string parsing, named colours from CSS Color Module Level 4, and nearest-colour matching in sRGB or CIE Lab.
- Colour output for PDF operators and for Acrobat JavaScript, from the same parsed value.
Images
- Native PNG and JPEG parsing, with other formats re-encoded through GD.
- Transparency, palettes, and ICC profiles, including an ICC profile as the base of an
/Indexedcolour space. - An indexed image carrying partial alpha is split into an image and its soft mask.
- Alternate images for print and display contexts, and caching keys for repeated assets.
- Placement helpers: automatic dimension derivation preserving aspect ratio, and stored dimensions scaled to a target box. See /examples/E037_image_methods/ .
- Clipping and masking. See /examples/E038_image_clipping/ .
- Input validation: PNG chunk checks, JPEG marker-chain walking for the ICC profile, and a 64 megapixel budget enforced before decoding.
Barcodes
Generated by tc-lib-barcode and drawn directly into the document. See /examples/E020_barcodes/ and /examples/E050_shipping_label_barcodes/ .
- Linear: Code 39 and its extended and checksummed variants, Code 93, Standard and Interleaved 2 of 5, Code 128 with subsets A, B and C, EAN-2, EAN-5, EAN-8, EAN-13, UPC-A, UPC-E, MSI, Codabar, Code 11, Pharmacode and Pharmacode two-track, and a raw 1D mode.
- Two-dimensional: Aztec (ISO/IEC 24778), Datamatrix (ISO/IEC 16022), PDF417 (ISO/IEC 15438), QR Code, and a raw 2D mode.
- Postal: POSTNET, PLANET, RMS4CC, KIX, and the Intelligent Mail Barcode in both raw and pre-processed forms.
- Symbology options are typed: QR error correction level and encoding mode, Datamatrix shape and encoding, Aztec hint and range.
Interactive Documents
- Annotations across the standard subtypes. See /examples/E027_annotations/ .
- AcroForm fields with appearance streams and default appearance resources. See /examples/E040_annotation_form/ .
- Document-level and field-level JavaScript. See /examples/E059_document_javascript/ .
- Embedded files and portfolio documents, with a typed
/AFRelationship. See /examples/E058_embedded_files_portfolio/ . - Bookmarks, table of contents, and index generation. See /examples/E044_toc_index/ .
- Viewer preferences, page layout and display modes, and navigation. See /examples/E051_viewer_preferences_navigation/ .
- User rights (Reader extensions). See /examples/E061_user_rights_reader_extensions/ .
Standards and Conformance
- PDF/A: parts 1, 2 and 3 at conformance levels a, b and u, with the ISO 19005 restrictions applied automatically (no encryption, no JavaScript, transparency suppressed where the part forbids it, appearance streams generated for annotations,
LZWDecodere-encoded). See /examples/E082_pdfa_core_fonts/ . - PDF/X: X-1a, X-3, X-4 and X-5, with forced CMYK where required, TrimBox handling, interactive subtypes dropped, and trapping status written to both the Info dictionary and XMP. See /examples/E010_pdfx/ through /examples/E014_pdfx5/ .
- PDF/UA: UA-1 and UA-2, with a structure tree and parent tree, heading level mapping, tagged text runs, links and figures,
/Altfrom image alt text,ActualTextfor ligatures, artifact helpers for headers and footers, layout bounding boxes for figures and tables, and/TUdescriptions on form fields. See /examples/E015_pdfua/ through /examples/E017_pdfua2/ , and /examples/E063_manual_tag_tree/ for manual tagging. - Output intents, with the bundled sRGB profile or a printing condition of your own supplied as an ICC file.
- Hybrid e-invoicing: Factur-X, ZUGFeRD 1 and 2, and Order-X payloads embedded in PDF/A-3, with the PDF/A extension schema and the conformance level written into XMP. See /examples/E001_invoice/ .
- Conformance warnings through
getWarnings()for the problems that cannot be fixed without discarding content.
Full guide: /docs/standards/ .
Encryption and Permissions
- Encryption algorithms: RC4-40, RC4-128, AES-128, AES-256 R5, and AES-256 R6 (PDF 2.0, ISO 32000-2). The RC4 modes are deprecated and emit a runtime notice.
- User and owner passwords, and permission flags per document operation. See /examples/E045_encryption_and_permissions/ .
- Optional metadata encryption control and embedded-file crypt filter selection.
- Public-key (certificate) encryption for multiple recipients, with signed permissions. See /examples/E056_encryption_cert_recipients/ .
- The decryption side of every mode, including public-key recipients, with
/Permsverification on AES-256 and reporting of which password matched. - Encryption dictionaries are verified against qpdf fixtures and against vectors computed from ISO 32000, for every revision from R2 to R6.
Digital Signatures
- Profiles: detached CMS (
adbe.pkcs7.detached) and PAdES baseline B-B, B-T, B-LT and B-LTA (ETSI EN 319 142-1). See /examples/E007_signature_basic/ through /examples/E009_signature_ltv/ and /examples/E081_signature_pades_lta/ . - SHA-256, SHA-384 and SHA-512 digests, with RSA and ECDSA signing keys.
- RFC 3161 timestamps, with the returned token verified against the request and the TSA certificate before it is embedded.
- LTV material: OCSP responses and CRLs fetched from the certificate extensions, each validated before it reaches the
/DSS,/VRI,/OCSPs,/CRLsand/Certsobjects. - Archive timestamps (
/Type /DocTimeStamp) throughupgradeToLta(). - Signing with a key this process cannot reach:
prepare()exports the/ByteRangedigest andapply()injects the returned CMS. See /examples/E075_external_signature_injection/ . - Two-phase signing, where a key service signs only the DER signed attributes and never sees the document. See /examples/E084_signature_two_phase_cms/ .
- Signature appearance placement, widget object access, and multiple signatures across incremental revisions. See /examples/E057_multisignature_incremental/ .
Full guide: /docs/digital-signatures/ .
Reading and Reusing Existing PDFs
- Register a source from a file path or from raw bytes, with the page count derived from the page tree actually reachable through
/Kids. - Import a page as a Form XObject, selecting which box to crop to and whether to respect page rotation. See /examples/E065_import_single_page/ .
- Place an imported page with aspect ratio control, nine-point alignment, and clipping, including N-up composition. See /examples/E067_import_page_region_nup/ .
- Append a whole document or a selected page list. See /examples/E066_import_document_append/ .
- Conformance-aware import: transparency groups suppressed where the mode forbids them,
LZWDecodere-encoded for PDF/A, and explicit exceptions where a stream cannot be made conformant. - Bounded parsing: decoded stream size, nesting depth, indirect object resolution depth, and chained cross-reference sections all capped, so a malformed document raises an exception rather than exhausting memory.
- Stream filters:
FlateDecode,LZWDecode,RunLengthDecode,ASCIIHexDecode,ASCII85Decode,CCITTFaxDecode,DCTDecode,JPXDecode,JBIG2Decode, andCrypt, singly or as a chain, with TIFF and PNG predictors.
Full guide: /docs/pdf-import/ .
Output and Metadata
getOutPDFString()returns the raw bytes;renderPDF()streams them. Storing to a file, returning from a controller, or attaching to a message are all the same call. See /examples/E049_output_targets_integration/ .- Flate compression control per document, applied to content streams, appearance and form XObjects, patterns, shaders, imported objects, and palettes.
- Reproducible output: pin the creation date, the modification date, and the file identifier to get the same bytes on every run.
- Separate document and instance identifiers, following the XMP definitions.
- Custom XMP fragments at five insertion points, checked for well-formedness in the namespace context of the insertion point. See /examples/E060_custom_xmp_metadata/ .
- Producer suffix for application identification, written to both the Info dictionary and XMP.
- XMP packet padding control, including the read-only zero-padding case.
Integration and Operations
- Typed backed enums for conformance modes, units, orientation, page boxes, layouts, alignment, fit modes, blend modes, path paint operators, filter types, font types, colour models, barcode types, signature profiles, digest algorithms, and text direction. Plain strings remain accepted everywhere. See /docs/enums/ .
- An optional external cache for font subsets and images behind a
CacheInterface, enabled per type. See /docs/cache/ . - Remote and local asset policy: host allowlists, path allowlists, and transport controls including TLS verification and timeouts. See /docs/remote-resources/ and /examples/E047_remote_resources_security/ .
- Independently versioned packages, so you can install the whole stack or only the parts you use. See /projects/ .
- Development workflow:
make qafor the full pipeline, preflight validation against veraPDF, and RPM and DEB packaging targets. See /docs/development/ . - PHP 8.2 or later, LGPL-3.0-or-later, installed with Composer.
Everything Runnable
All 85 examples, each with its rendered PDF and its source, are at /examples/ . The generated API reference is at /docs/srcdoc/tc-lib-pdf .