Skip to content

Configure the NextPDF Symfony bundle

Configure all bundle behavior under the nextpdf root key in config/packages/nextpdf.yaml. Every key has a default, so you only set values you want to change. This page mirrors Configuration.php exactly.

NextPDF\Symfony\DependencyInjection\Configuration defines the schema. Invalid values fail at container build time with a Symfony InvalidConfigurationException.

KeyTypeDefaultValidation
page_formatenumA4one of A4, A3, A5, Letter, Legal, Tabloid
orientationenumPone of P, L
unitenummmone of pt, mm, cm, in
pdfascalarnullone of null, 4, 4e, 4f
fonts_pathscalar%kernel.project_dir%/resources/fonts
cache_pathscalar%kernel.cache_dir%/nextpdf
image_cache_mbinteger50minimum 0
font_cache_lockingbooleantrue
preload_fontslist of strings[]
KeyTypeDefault
icc_profile.rgbscalarnull
icc_profile.cmykscalarnull

Applies to every document PdfFactory produces.

KeyTypeDefault
defaults.creatorscalarNextPDF
defaults.authorscalar(empty)
defaults.languagescalaren
defaults.margin_topfloat10.0
defaults.margin_rightfloat10.0
defaults.margin_bottomfloat10.0
defaults.margin_leftfloat10.0
defaults.font_familyscalardejavusans
defaults.font_sizefloat12.0
defaults.trim_boxvariablenull
defaults.bleed_boxvariablenull

PdfFactory reads creator, author, and language from this section and applies them to each new document. The bundle stores the remaining keys as container parameters for engine use.

Applies only when nextpdf/artisan is installed and detected.

KeyTypeDefault
artisan.chrome_binaryscalarnull
artisan.render_timeoutinteger30
artisan.default_cssscalar(empty)
artisan.no_sandboxbooleanfalse
artisan.max_html_sizeinteger5000000

Applies only when nextpdf/premium is installed. When the bundle and Pro tier are present, the supported signing configuration is the baseline B-B profile. The level node accepts the string values below for schema compatibility with the wider NextPDF configuration family. This bundle delivers B-B signing capability. Profiles beyond B-B are documented separately in the NextPDF Premium documentation and are not claimed here.

KeyTypeDefaultValidation
signature.enabledbooleanfalse
signature.certificatescalarnull
signature.private_keyscalarnull
signature.passwordscalar(empty)
signature.extra_certslist of strings[]
signature.levelenumB-Baccepted set: B-B, B-T, B-LT, B-LTA (B-B delivered; B-T/B-LT/B-LTA are schema-compatibility values, not delivered Pro capability)

The compiler pass registers a signer service only when signature.enabled is true and signature.certificate is set; otherwise, the section is inert.

Time Stamp Authority (TSA) client configuration, used by Pro signing when configured.

KeyTypeDefault
tsa.urlscalarnull
tsa.usernamescalar(empty)
tsa.passwordscalar(empty)
tsa.certscalarnull
tsa.keyscalarnull
tsa.timeoutinteger30
tsa.allow_insecure_httpbooleanfalse
tsa.pinned_public_keyslist of strings[]
tsa.warn_on_key_rotationbooleantrue

The bundle registers a TSA client service only when tsa.url is set.

KeyTypeDefault
ocsp_cache.enabledbooleantrue
ocsp_cache.ttlinteger86400
ocsp_cache.directoryscalarnull

Settings for asynchronous generation, consumed when symfony/messenger is installed.

KeyTypeDefault
messenger.transportscalarasync
messenger.timeoutinteger120
messenger.retriesinteger3

A configuration file that shows every section with its defaults:

nextpdf:
page_format: A4
orientation: P
unit: mm
pdfa: ~
fonts_path: '%kernel.project_dir%/resources/fonts'
cache_path: '%kernel.cache_dir%/nextpdf'
image_cache_mb: 50
font_cache_locking: true
preload_fonts: []
icc_profile:
rgb: ~
cmyk: ~
defaults:
creator: NextPDF
author: ''
language: en
margin_top: 10.0
margin_right: 10.0
margin_bottom: 10.0
margin_left: 10.0
font_family: dejavusans
font_size: 12.0
trim_box: ~
bleed_box: ~
artisan:
chrome_binary: ~
render_timeout: 30
default_css: ''
no_sandbox: false
max_html_size: 5000000
signature:
enabled: false
certificate: ~
private_key: ~
password: ''
extra_certs: []
level: B-B
tsa:
url: ~
username: ''
password: ''
cert: ~
key: ~
timeout: 30
allow_insecure_http: false
pinned_public_keys: []
warn_on_key_rotation: true
ocsp_cache:
enabled: true
ttl: 86400
directory: ~
messenger:
transport: async
timeout: 120
retries: 3

The bundle loads its service definitions from config/services.php. The table below mirrors that file exactly.

Service idSharedPublicNotes
NextPDF\Typography\FontRegistryyesconstructed from nextpdf.fonts_path; optional PHP Standard Recommendation 3 (PSR-3) logger
NextPDF\Contracts\FontRegistryInterface(alias)yesalias of FontRegistry
NextPDF\Graphics\ImageRegistryyesbounded least-recently-used (LRU); tagged kernel.reset (reset)
NextPDF\Core\DocumentFactoryyesshares the two registries
NextPDF\Contracts\DocumentFactoryInterface(alias)yesalias of DocumentFactory
NextPDF\Symfony\Service\PdfFactoryyesyesreads defaults, pdfa, and artisan parameters
NextPDF\Contracts\PdfDocumentInterfacenoyesfactory [PdfFactory, create]
NextPDF\Core\Document(alias)alias of PdfDocumentInterface
nextpdf.document(alias)yesalias of PdfDocumentInterface
NextPDF\Symfony\Http\PdfResponseyesstateless helper

The bundle also registers EInvoice contract bindings (EmbedderInterface, ValidatorInterface, ProfileInterface, SchematronRunnerInterface) only when the corresponding Premium implementation classes exist. Each service is non-shared, so callers receive a fresh instance. Per-call parser state never leaks across requests.

nextpdf.document (and its aliases) is non-shared: every container resolution returns a distinct document. Under PHP Standard Recommendation 11 (PSR-11), a container may return a different value on successive get() calls with the same identifier; see PSR-11 §1.1.2. The font registry is shared and locked after warmup. Structural font data is parsed once per process and cannot be mutated mid-request.

The FontRegistry and ImageRegistry services accept an optional Psr\Log\LoggerInterface; Symfony binds it with nullOnInvalid(). The logger remains an optional, swappable collaborator, consistent with the PSR-3 logger contract.

PdfFactory, PdfResponse, the document factory interface, and the font registry interface are public. They can be fetched from the container or type-hinted in autowired controllers and services. Constructor injection of NextPDF\Symfony\Service\PdfFactory is the recommended entry point.

  • pdfa set without Pro — the value is stored but ignored. PdfFactory applies Portable Document Format/Archival (PDF/A) only when the Pro extension is detected at compile time.
  • image_cache_mb: 0 — valid; disables the image LRU cache. Negative values are rejected at build time.
  • signature.enabled: true without signature.certificate — the signer service is not registered; the configuration is silently inert by design.
  • %kernel.*% placeholdersfonts_path and cache_path defaults use Symfony container parameters; override with absolute paths only when the literal path is required.

Each row is a normative claim on this page, pinned to a full 64-hex reference_id from the gated standards development organization (SDO) corpus. Provenance, including corpus manifest and retrieval transport, is in _sidecars/rag-citations.yaml.

SpecClausereference_idClaim
PSR-11psr_11_container#1.1.2.p3.bget() may return different values per resolution
PSR-3psr_3_logger#x3.p17Optional LoggerInterface collaborator

The signature and tsa sections apply only when nextpdf/premium (Pro) is installed. This optional Pro capability requires no code change in the Core bundle documented here. See </get-license/?intent=symfony-pro>.

  • /integrations/symfony/install/ — install and register the bundle.
  • /integrations/symfony/overview/ — review the capability summary.
  • /integrations/symfony/production-usage/ — worker safety and asynchronous patterns.
  • /integrations/symfony/boot-and-discovery/ — see how the configuration is resolved during boot.