tecnickcom/tc-lib-pdf-graph
Low-level geometric drawing and transformation primitives for PDF content streams. Compose paths, lines, curves, clipping, stroke/fill styles, gradients and shading, plus matrix transforms and coordinate helpers, with PDF/A-aware behavior.
Architecture fit. tc-lib-pdf-graph is not a PDF generator — it is a low-level primitive layer that emits PDF graphics operators (paths, Bézier curves, clipping, stroke/fill styles, transformation matrices, gradient/shading dictionaries) into a content stream. It does not own document structure, pages, object/xref tables, or output. That work belongs to its parent, tecnickcom/tc-lib-pdf. For a Laravel application, this means the package is almost never the correct unit of adoption: it should arrive as a transitive dependency of tc-lib-pdf (or a TCPDF-family stack), and only be used directly when the product needs vector drawing, custom chart rendering, or a bespoke layout engine that the higher-level facade does not expose.
Integration feasibility. Mechanically straightforward: Composer install, PSR-4 autoload under \Com\Tecnick\Pdf\Graph, no framework coupling, no service provider required. The hard constraints are (a) PHP >= 8.2, which effectively pins the host application to Laravel 11/12 and precludes Laravel 9/10 estates until upgraded; (b) the zlib extension, which is present in virtually all standard builds but should be asserted in deployment checklists for minimal containers; and (c) two constructor collaborators, \Com\Tecnick\Color\Pdf and \Com\Tecnick\Pdf\Encrypt\Encrypt, which must be provided and correctly configured — particularly the encryption object, whose mode affects PDF/A behavior.
Technical risk. The dominant risks are not runtime but structural:
getClippingRect, matrix transforms, style state). Developers without PDF spec familiarity will produce subtly wrong output — coordinate origin confusion (PDF is bottom-left, most UI/canvas systems are top-left), unbalanced q/Q graphics-state save/restore, or unregistered color/gradient resources referenced by name but never added to the page resource dictionary.NOASSERTION while the README declares GNU LGPL v3. This is a scanner-detection gap, not necessarily a real conflict, but LGPL in a distributed PHP product needs a legal opinion — especially if the application is shipped as a SaaS with on-premise or white-label variants.Key questions.
tc-lib-pdf) or "draw custom vector geometry inside a PDF" (→ this package is relevant)? These lead to very different scoping.pdfa constructor flag and encryption object change output semantics materially and must be validated against a target profile.Stack fit. The package is framework-agnostic and cleanly composable. The idiomatic Laravel shape is a thin wrapper: bind a configured Draw instance (page dimensions, unit scale, color and encryption collaborators) through a service provider, resolve it in a dedicated PdfDrawingService, and keep all \Com\Tecnick\Pdf\Graph imports confined to that namespace. Artisan commands and queued jobs should consume the wrapper, never the vendor classes directly.
Migration path. Do not adopt this package in isolation. Sequence it as:
tc-lib-pdf and let Composer resolve tc-lib-pdf-graph as a dependency. Adopting the graph layer alone yields no usable PDF output.barryvdh/laravel-dompdf, mpdf, or legacy TCPDF, generate the same documents from both paths and diff visually and structurally (page count, embedded fonts, file size, text extractability).Compatibility. Verify Composer resolution against the target Laravel minor version in CI, not locally. The PHP 8.2 requirement is the gating item; the zlib requirement is the silent-failure item in slim Docker images. Confirm that the Color and Encrypt collaborator versions resolved by Composer are the ones the Draw constructor expects — cross-package version skew inside the tc-lib-pdf family is the most likely source of confusing runtime errors.
Sequencing. Recommended order: (1) licensing sign-off; (2) PHP 8.2 readiness across app, workers, and CI; (3) proof-of-concept producing one production-representative document with custom vector content; (4) wrapper service + tests; (5) parallel-run and cutover. Budget the POC as the real decision gate — it will surface coordinate-system and resource-registration issues that no amount of reading the README will.
Maintenance. Low surface area, low churn: the package is a primitive layer with a stable, PDF-spec-anchored contract, so breaking changes should be rare and semantically meaningful when they occur. The maintenance burden shifts to your wrapper — pin the version in composer.json, treat minor bumps as routine, and read the changelog for anything touching graphics state or PDF/A behavior. The single-maintainer model means you should be prepared to fork; the LGPL permits it, and the codebase is small enough that a fork is a realistic contingency rather than an empty threat.
Support. Community-only: GitHub issues, no SLA, no commercial backing (sponsorship is voluntary). Escalation for a production PDF defect is therefore internal. The practical mitigation is a strong test harness — golden-file assertions on generated PDFs (byte-stable where possible, structural assertions otherwise) so that regressions are caught by your CI rather than by customers.
Scaling. Generation is CPU-bound and synchronous by nature; the library holds drawing state in memory and complex paths (thousands of segments, dense gradients) grow the content stream and peak memory proportionally. Run generation in queued jobs with explicit memory limits and timeouts rather than in request handlers. Horizontal scaling is trivial — it is stateless and shares nothing — so the constraint is per-job memory, not concurrency. Watch for pathological inputs (user-supplied chart data with unbounded point counts) and cap them at the application layer.
Failure modes. Expect: malformed content streams from unbalanced graphics-state operators (corrupt or blank renders in some viewers but not others); missing resource-dictionary entries producing silent blank fills or gradients; coordinate-origin mistakes producing geometrically plausible but wrong output that passes smoke tests; PHP fatal errors on memory exhaustion for large paths; and PDF/A validation failures when the pdfa flag or encryption configuration is inconsistent with the surrounding document. Note that the first two classes of failure are viewer-dependent — validate against at least Acrobat, a browser-native renderer, and a headless extractor (e.g. pdftotext/qpdf --check).
Ramp-up. Steep for anyone without PDF-graphics background, moderate for anyone who has worked with TCPDF or raw content streams. Realistic estimate: one to two days for a competent PHP developer to produce a correct custom drawing, and roughly a week before they can debug rendering anomalies independently. Given the 5-star / 0-dependent profile, assume zero internal prior art and budget a short internal spike plus a written "how we draw" note before the first production use.
How can I help you explore Laravel packages today?