Repository navigation
Add TcLibPdf engine (tc-lib-pdf), deprecate Tcpdf engine - #339
Merged
Merged
Conversation
Add a new TcLibPdfEngine backed by the actively maintained tecnickcom/tc-lib-pdf library, the successor of the now upstream-deprecated tecnickcom/tcpdf package. The existing TcpdfEngine is marked deprecated and points users to the new engine. The engine renders the CakePdf HTML via tc-lib-pdf's addHTMLCell(), maps orientation and page size from the CakePdf instance, honors the standard CakePdf margin setting (with an engine-specific margins fallback), and exposes unit, unicode, font, metadata and conformance mode options under the documented options config key. Unlike tcpdf, tc-lib-pdf ships no fonts, so the standard PDF core fonts must be provided as generated JSON files via the K_PATH_FONTS constant. This is documented in the README. The core-14 font definitions used by the engine test are bundled under tests/fonts (metric data generated from the URW base35 fonts; see tests/fonts/README.md for provenance).
Cast CakePdf::margin() (typed static|array) to array before array access so psalm no longer reports an undefined offsetGet on the static branch. Raise the tecnickcom/tc-lib-pdf constraint to ^8.5: the HTML rendering API (addHTMLCell) the engine relies on was introduced in 8.5.0, so the previous ^8 floor failed on the prefer-lowest build.
The lowest tc-lib-pdf-font release (2.6.4) types Stack::insert() $size as ?int, while newer releases accept float. Cast to int so the prefer-lowest build works across the whole supported range.
ADmad
reviewed
Jun 19, 2026
ADmad
reviewed
Jun 19, 2026
Member
Author
|
It actually wasnt too difficult to set the font and replace the deprecated one: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
TcLibPdfEnginebacked by the actively maintainedtecnickcom/tc-lib-pdflibrary, thesuccessor of the now upstream-deprecated
tecnickcom/tcpdfpackage. Theexisting
TcpdfEngineis marked@deprecatedand points to the new engine.Why
tecnickcom/tcpdfis flagged as deprecated on Packagist ("Deprecated legacy PDFengine for PHP"). tc-lib-pdf is the maintained rewrite from the same author and
keeps HTML to PDF support via
addHTMLCell().What it does
addHTMLCell()(which flows longcontent across pages automatically).
orientationandpageSizefrom the CakePdf instance.marginsetting, with an engine-specificoptions.marginsfallback per side.unit,unicode,subsetFont,compress,mode(PDF/A, PDF/X,PDF/UA conformance),
fontandmetadataunder the documentedoptionsconfig key.
TcpdfEnginedeprecated.Fonts requirement
Unlike tcpdf, tc-lib-pdf ships no fonts. Consumers must provide the standard PDF
core fonts as generated
*.jsonfiles via theK_PATH_FONTSconstant. This isdocumented in the README. The engine test bundles the core-14 font definitions
under
tests/fonts/so CI can render real PDFs.Note
The bundled font metric data was generated from the URW base35 fonts
(
fonts-urw-base35, AGPLv3 with font exception), which are metric-compatiblewith the standard PDF core fonts. The core 14 are referenced by name and not
embedded, so these files carry only metrics and encoding tables, no glyph
outlines. See
tests/fonts/README.md. Happy to swap the fixtures for fontsgenerated via tecnickcom's own tooling if preferred for licensing clarity.
Notes
tecnickcom/tc-lib-pdf: ^8added torequire-devandsuggest.