phil / print-preflight-bundle
phil/print-preflight in Symfony: printer profiles from the configuration, checks added by attribute, documents measured in a browser read from JSON, a console check, and layouts recorded while phil/paged-media draws, with fonts from phil/fonts-bundle and images from phil/media-bundle
Package info
github.com/parler-haut-interagir-librement/print-preflight-bundle
Type:symfony-bundle
pkg:composer/phil/print-preflight-bundle
Requires
- php: >=8.5
- phil/fonts: ^0.1@dev
- phil/print-preflight: ^0.1@dev
- symfony/config: ^8.2
- symfony/console: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/filesystem: ^8.2
Requires (Dev)
- ext-mbstring: *
- ext-zlib: *
- phil/fonts-bundle: ^0.1@dev
- phil/media-bundle: ^0.1@dev
- phil/paged-media: ^0.1@dev
- phpunit/phpunit: ^13.4
- psr/clock: ^1.0
- symfony/event-dispatcher: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-kernel: ^8.2
Suggests
- phil/fonts-bundle: To name the fonts of a measured document by family, weight and style
- phil/media-bundle: For MediaImages, the images of the media library placed on a page
- phil/paged-media: For PdfLayout, which records what the native PDF writer places
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-13 22:46:27 UTC
README
What a printer would refuse, checked in a Symfony application against the printers it sends to.
phil/print-preflight-bundle puts phil/print-preflight in a Symfony application. The printers' rules — trim sizes,
bleed, safety margin, resolution, page counts, colour workflow, ink coverage, line width, overprint, transparency,
severities — are named profiles of the configuration, written in millimetres, inches, points or CSS pixels. One service,
Preflighter, runs the library's checks and the application's own, registered by an attribute. A document laid out in a
browser is measured by a script and sent as JSON, which MeasuredDocument reads; a document drawn with the native PDF
writer of phil/paged-media is recorded by PdfLayout as it is drawn; an image of phil/media-bundle is placed with
the pixel size the library recorded; and a font named by family, weight and style is found, with its embedding
permissions, in the catalogue of phil/fonts-bundle. A command checks a measured document and fails a build on an
error.
It is for any Symfony application that sends files to print: a book or zine editor that shows the problems page by page, a print-on-demand storefront, a pipeline that renders to PDF.
It is a bundle built on symfony/config, symfony/dependency-injection, symfony/console and
symfony/filesystem. phil/fonts-bundle, phil/paged-media and phil/media-bundle are optional: each integration is
registered when its package is installed.
Status
| Part | State |
|---|---|
| Configuration: printer profiles by name, lengths and sizes as text, a default profile | Implemented and tested |
Preflighter and #[AsPreflightCheck] |
Implemented and tested |
MeasuredDocument: a document measured in a browser, read from JSON |
Implemented and tested |
phil:print-preflight:check: findings as text or JSON, failing on an error |
Implemented and tested |
PdfLayout for phil/paged-media, MediaImages for phil/media-bundle, CatalogueFontResolver for phil/fonts-bundle |
Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, installing and enabling the bundle. |
| Configuration | Profiles, lengths and sizes, and the services they give. |
| Checking | Preflighter, the checks of the application, and the command. |
| Measured documents | The JSON a script on the rendered page sends, and MeasuredDocument. |
| Integrations | PdfLayout, MediaImages and the fonts of phil/fonts-bundle. |
| Extension points | The services and ports an application relies on or replaces. |
| Exceptions | What the bundle throws, beside the library's exceptions. |
| Testing | The bundle's tests, and testing an application that uses it. |
| Reference | Every class and service of the bundle. |
Quick start
composer require phil/print-preflight-bundle
# config/packages/phil_print_preflight.yaml phil_print_preflight: profiles: booklet: { trim_sizes: [a5], bleed: 3mm, minimum_pages: 8, page_multiple: 4 } poster: { trim_sizes: [a4, 297x210mm], bleed: 5mm, colour_workflow: rgb }
$report = $preflighter->check($measuredDocument->fromJson($request->getContent()), 'booklet'); foreach ($report->forPage(1) as $finding) { // show $finding->message beside the page }
bin/console phil:print-preflight:check var/measured/zine.json --profile=booklet
Requirements
PHP 8.5 or later, Symfony 8.2, phil/print-preflight and phil/fonts; phil/fonts-bundle to name fonts by family;
phil/paged-media for PdfLayout; phil/media-bundle for MediaImages.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.