Skip to content

Configure the NextPDF Laravel package

config/nextpdf.php is published by php artisan vendor:publish --tag=nextpdf-config. Every key has an environment-variable fallback and a hard-coded default. This page lists each key as it appears in the package’s config/nextpdf.php.

Terminal window
php artisan vendor:publish --tag=nextpdf-config

During register(), the provider also merges the package defaults under the nextpdf config key. Unset keys then fall back to the values below, even before you publish the config file.

Most environment variables accept either a NEXTPDF_* name or a legacy TCPDF_* name. The legacy prefix is available during the transition period documented in UPGRADE.md. Use NEXTPDF_* for new deployments. The config file resolves values in this order: environment variable → published file value → package default.

KeyEnv (primary)DefaultEffect
page_formatNEXTPDF_PAGE_FORMATA4Default page format: A4, A3, A5, Letter, Legal, or Tabloid
orientationNEXTPDF_ORIENTATIONPPortrait (P) or landscape (L)
unitNEXTPDF_UNITmmMeasurement unit: pt, mm, cm, or in
defaults.creatorNEXTPDF_CREATORNextPDFDocument creator metadata; applied to the PdfDocumentInterface binding
defaults.authorNEXTPDF_AUTHOR(empty)Author metadata; applied only when non-empty
defaults.languageNEXTPDF_LANGenDocument language; applied to the document binding
defaults.margin_top / _right / _bottom / _left10Default margins
defaults.font_familydejavusansDefault font family
defaults.font_size12Default font size
defaults.trim_boxnullTrimBox [left, bottom, right, top] in points, or null
defaults.bleed_boxnullBleedBox [left, bottom, right, top] in points, or null

The provider applies defaults.creator, defaults.language, and (when set) defaults.author to each newly resolved document. The provider skips defaults.author when the value is empty.

KeyEnv (primary)DefaultEffect
pdfaNEXTPDF_PDFAnullPDF/A archival level: null, 4, 4e, or 4f. A non-null value enables PDF/A on the document binding and requires nextpdf/premium
fonts_pathNEXTPDF_FONTS_PATHresource_path('fonts')Directory for additional TrueType fonts; sets the font registry search path
cache_pathNEXTPDF_CACHE_PATHstorage_path('framework/cache/tcpdf')Parsed-font and temporary-file cache directory
icc_profile.rgbNEXTPDF_ICC_PROFILE_RGBnullRGB ICC profile path; required for PDF/A
icc_profile.cmykNEXTPDF_ICC_PROFILE_CMYKnullOptional CMYK ICC profile for print workflows
font_cache_lockingNEXTPDF_FONT_CACHE_LOCKINGtrueUse flock for the font cache to prevent corruption when concurrent queue workers write

A non-null pdfa value requires the Premium tier. Without nextpdf/premium, resolving the document binding with pdfa set raises a class-not-found error for the PDF/A version type. This page does not document Premium archival behavior. See the Premium documentation.

KeyEnv (primary)DefaultEffect
preload_fonts[]Absolute font-file paths parsed at worker boot. The font registry is locked after warmup
image_cache_mbNEXTPDF_IMAGE_CACHE_MB50Least recently used (LRU) image-cache budget in megabytes (MB). 0 disables caching. No upper bound is enforced at the provider level

The image-cache budget has no provider-enforced upper bound. Use a container memory limit or php.inimemory_limit to bound it. The config file recommends a practical maximum of 256 MB.

KeyEnv (primary)DefaultEffect
signature.enabledNEXTPDF_SIGN_ENABLEDfalseWhen false, or when the certificate is empty, SignerInterface resolves to null
signature.certificateNEXTPDF_SIGN_CERTnullSigning certificate path
signature.private_keyNEXTPDF_SIGN_KEYnullPrivate key path
signature.passwordNEXTPDF_SIGN_PASSWORD(empty)Key passphrase
signature.extra_certs[]Intermediate CA certificate paths
signature.levelNEXTPDF_SIGN_LEVELB-BPDF Advanced Electronic Signatures (PAdES) baseline level passed to the signer

The Core package documented here does not ship a signer implementation; SignerInterface resolves to null until nextpdf/premium provides one. With Premium, level: B-B produces a PAdES B-B baseline signature. Higher PAdES baselines depend on a configured timestamp authority and Premium capability; this page does not document those levels.

KeyEnv (primary)DefaultEffect
tsa.urlNEXTPDF_TSA_URLnullTimestamp authority (TSA) endpoint. When empty, TsaClient resolves to null
tsa.username / tsa.passwordNEXTPDF_TSA_USERNAME / _PASSWORD(empty)TSA HTTP credentials
tsa.cert / tsa.keyNEXTPDF_TSA_CERT / _KEYnullClient certificate / key for mutual Transport Layer Security (mTLS) to the TSA
tsa.timeoutNEXTPDF_TSA_TIMEOUT30HTTP timeout in seconds for the PSR-18 client
tsa.pinned_public_keys[]Base64 SHA-256 SubjectPublicKeyInfo (SPKI) pins (RFC 7469). Empty disables pinning
tsa.warn_on_key_rotationNEXTPDF_TSA_WARN_ROTATIONtrueEmit a warning when the TSA presents a non-pinned SPKI
tsa.allow_insecure_httpNEXTPDF_TSA_ALLOW_INSECURE_HTTPfalsePermit plaintext HTTP to the TSA. Leave false in production
KeyEnv (primary)DefaultEffect
ocsp_cache.enabledNEXTPDF_OCSP_CACHE_ENABLEDtrueCache Online Certificate Status Protocol (OCSP) responses during validation
ocsp_cache.ttlNEXTPDF_OCSP_CACHE_TTL86400Cache TTL in seconds
ocsp_cache.directoryNEXTPDF_OCSP_CACHE_DIRnullCache directory; null keeps the cache in memory only
KeyEnv (primary)DefaultEffect
queue.connectionNEXTPDF_QUEUE_CONNECTIONnullQueue connection; null uses the default connection
queue.queueNEXTPDF_QUEUE_NAMEpdfQueue that GeneratePdfJob is pushed to
queue.timeoutNEXTPDF_QUEUE_TIMEOUT120Per-job timeout in seconds
KeyEnv (primary)DefaultEffect
artisan.chrome_binaryNEXTPDF_ARTISAN_CHROME_BINARYenv value or unsetPath to the Chrome/Chromium binary
artisan.render_timeoutNEXTPDF_ARTISAN_RENDER_TIMEOUT30Render timeout in seconds
artisan.default_cssNEXTPDF_ARTISAN_DEFAULT_CSS(empty)Default CSS injected into rendered HTML
artisan.no_sandboxNEXTPDF_ARTISAN_NO_SANDBOXfalseDisable the Chrome sandbox
artisan.max_html_sizeNEXTPDF_ARTISAN_MAX_HTML_SIZE5000000Maximum HTML input size in bytes

The artisan section applies to the document binding only when a Chrome browser-factory class is present (the nextpdf/artisan extension). When that class is absent, the section is ignored.

resource: config/nextpdf.php (subset, verified against the published file)
<?php
declare(strict_types=1);
return [
'page_format' => env('NEXTPDF_PAGE_FORMAT', 'A4'),
'orientation' => env('NEXTPDF_ORIENTATION', 'P'),
'unit' => env('NEXTPDF_UNIT', 'mm'),
'pdfa' => env('NEXTPDF_PDFA', null),
'fonts_path' => env('NEXTPDF_FONTS_PATH', resource_path('fonts')),
'preload_fonts' => [],
'image_cache_mb' => env('NEXTPDF_IMAGE_CACHE_MB', 50),
'queue' => [
'connection' => env('NEXTPDF_QUEUE_CONNECTION', null),
'queue' => env('NEXTPDF_QUEUE_NAME', 'pdf'),
'timeout' => env('NEXTPDF_QUEUE_TIMEOUT', 120),
],
];
  • signature.enabled = true with an empty signature.certificate still resolves SignerInterface to null; both values must be set.
  • tsa.url = null forces TsaClient to null, even if other tsa.* keys are populated.
  • signature.level = null falls back to PAdES B-B on the signer.
  • image_cache_mb set to null (not 0) falls back to the 50 MB default; 0 explicitly disables caching.
  • Legacy TCPDF_* environment variables remain readable but are deprecated. Migrate to NEXTPDF_*.

Reading config uses O(1) array access. preload_fonts trades a one-time O(f) parse at worker boot for lower first-request latency. A larger image_cache_mb reduces repeated image decoding at the cost of process-resident memory.

tsa.allow_insecure_http weakens timestamp trust and must stay false in production. TSA URLs should come from trusted configuration only. If you expose them through an admin surface, use egress firewall or DNS policy to mitigate request forgery. See /integrations/laravel/security-and-operations/.

No normative standard governs the configuration file shape. All keys are verified against the package’s config/nextpdf.php at the documented revision. Premium governs signature-level semantics, which are outside the scope of this Core page.

The signature and tsa sections drive Premium signing when nextpdf/premium is installed. This optional Enterprise capability requires no Core package code changes. See https://nextpdf.dev/get-license/?intent=laravel-signing.

  • /integrations/laravel/install/ — publish the config file
  • /integrations/laravel/production-usage/ — see configuration applied in a real controller
  • /integrations/laravel/security-and-operations/ — harden the TSA and queue settings
  • /integrations/laravel/boot-and-discovery/ — see which binding each key drives