This release adds support for Laravel 11 and WeasyPrint 61. Versions 61.0 and 61.1 are not supported due to a security issue noted here.
Version 8 of the package will be the last to support PHP 8.1 and versions of WeasyPrint < 61.
This release drops support for WeasyPrint < v59. If you are constrained to an older version, an older version of the package that supports that version will be required.
Going forward, compatibility of this package against a particular WeasyPrint version will be based solely on CLI flags available in that version.
- If a CLI property is removed in a WeasyPrint release, then it will become unsupported in a new version of the package.
- If one is added, then it will be unsupported until a new version of the package is released.
In general, only the latest major version of WeasyPrint and, by extension, the package will be supported at any given time. However, where CLI flags do not change between versions, and WeasyPrint only updates internal features in relation to rendering PDFs, then all such versions will continue to be supported. An example of this is WeasyPrint 59.0 → 60.0, where CLI flags did not change.
If you are using an unsupported version of WeasyPrint, attempts to build a PDF will fail with an exception.
- Service instances may now only be resolved via the Service Container (
Service::new()
has been removed in favour ofService::instance()
). - The default config is now class-based to introduce some type-safety.
- Runtime config may now only be tapped (using
tapConfig
) or overridden (usingsetConfig
). - The default
timeout
is now 60 seconds. - The
optimizeSize
config option has been removed. - The
skipCompression
,optimizeImages
,fullFonts
,hinting
,dpi
,jpegQuality
,pdfForms
config options have been added. - Some config options are now validated, including the new
dpi
andjpegQuality
options, as well as existingmediaType
andinputEncoding
options. An exception will be thrown if these options are invalid. - All tests have been moved to Pest 2. Coverage removed for the time being.
This release adds support for WeasyPrint 58, along with two new configuration properties, pdfVersion
and pdfVariant
, which may only be used in versions 58 and greater. Custom meta-data has not been added in this release.
Note: Support for WeasyPrint 59 and 60 to come in the next major package release, which will drop support for older versions of WeasyPrint.
This release adds support for Laravel 10 and drops support for Laravel 8. The minimum-required version of PHP is now 8.1. As there have been no significant API changes to WeasyPrint, this package continues to support v53+.
Unsupported Versions
This release adds support for Laravel 9, and works just fine with WeasyPrint v54.
This version is specifically designed around WeasyPrint v53, which drops support for PNGs due to its new rendering engine. Overall, this simplifies things from an interface perspective – you only need to prepare the source, build the Output
, and do what you need with it.
Over and above the changes noted below, the package now requires Laravel 8.47+, which adds support for scoped singletons. In the previous version (v5) of this package, the singleton was immutable, which meant that every mutable-by-design method would actually return a cloned instance of the service.
- The configuration file now supports environment variables, which generally removes the need to publish it. See the readme for a list of available options.
- The
to()
,toPdf()
andtoPng()
methods have been removed. - Likewise, the
OutputType
enumeration class has been removed. Under the hood, the--format
flag has been removed. - The
optimizeImages
config option has been removed in favor ofoptimizeSize
. - The
resolution
config option has been removed, due to lack of PNG support.
- The
binary
config option previously declared a sensible default of/usr/local/bin/weasyprint
. However, this may not always be the case as WeasyPrint may be installed in a virtual environment, which does not conform to that path. Additionally, some Linux distros place the binary elsewhere on the system. With the removal of this default, the package will attempt to locate the binary, which means it needs to be in yourPATH
. If it is not in your path, and you do not want it to be, simply set the absolute path to the binary in your environment usingWEASYPRINT_BINARY
. - Due to the addition of the scoped singleton, the service class is no longer immutable. Any method that previously cloned the service will no longer do so.
- Internally, the package now uses a pipeline to prepare everything and call the WeasyPrint binary.
- Adds full support for the Laravel Service Container with a new service-based architecture
- Laravel Octane compatibility
- A new config-based setup, instead of fluent helpers
- Adds the ability to pass the
--optimize-images
flag to WeasyPrint via theoptimizeImages
config option (requires v52 or greater) - Adds the ability to save output as a file using Laravel’s Filesystem through the
putFile
method on the newOutput
object - Improved explicit output types and implicit output type inference.
Given that v5 is a paradigm release, the following changes are considered breaking. Whilst upgrade steps are shown here, they are not detailed, and so an upgrade guide is also available for you to work through.
- The static
make
method is no longer available. UseprepareSource($source)->build()
orcreateFromSource($source)->build()
(when using service-class instantiation) instead. - The
view
method is also gone, and the package therefore no longer accepts data to pass to a view on your behalf. Instead, pass aRenderable
hydrated with data (such as a Laravel View) toprepareSource
. - Both
toPdf
andtoPng
no longer return the rendered data in raw form. They are merely shorthands forto(OutputType::pdf())
andto(OutputType::png())
, respectively. To get the data in raw form, callbuild()->getData()
. - The
download
andinline
methods now return an instance ofSymfony\Component\HttpFoundation\StreamedResponse
instead ofIlluminate\Http\Response
. - The
set*
andadd*
(except foraddAttachment
) configuration helpers are no longer available. Instead, pass the config intonew()
ormergeConfig()
. The default config has been expanded to include all the possible options.
- The
download
andinline
methods may now be called either on the service or on the output returned frombuild()
. If it is called on the service,build()
will be called for you, with the file type inferred from the extension, which defaults to.pdf
if not provided.
- Drops support for PHP < 7.3
- Drops support for Laravel < 7.0
- Upgrades
orchestra/testbench
to v6 - Adds class coverage to test suite
- Adds support for
symfony/process
v5
- Adds support for Laravel 7
- Drops the
convert
method in favor of only usingtoPdf
,toPng
,download
orinline
- Adds more
set*
andadd*
fluent configuration helpers:addAttachment
to add an--attachment
setResolution
to set the--resolution
setMediaType
to set the--media-type
setPresentationalHints
to toggle--presentational-hints
setOutputEncoding
to set the--encoding
- Throws
InvalidOutputModeException
when the output mode is notpdf
orpdf
- Adds support for URLs
- Does not re-convert if the output is already available
- Adds the
toPdf
andtoPng
shorthand helpers
- Adds stylesheet support with
addStylesheet
- [Internal] Adds a GitLab CI pipeline for testing the package
- [Internal] Adds an ISC license file
- [Readme] Documents the
download
andinline
methods
- Adds support for setting a base URL with
setBaseUrl
- Adds
download
andinline
helpers
- [Internal] Adds proper tests
- Corrects the
view
method to be static, as intended
- Initial Release