Snappy v2 #467
Replies: 9 comments 11 replies
-
Here is the draft PR for the v2 #468 (still in progress) |
Beta Was this translation helpful? Give feedback.
-
FYI #462 |
Beta Was this translation helpful? Give feedback.
-
@AntoineLelaisant it is also the occasion to drop support of deprecated versions of |
Beta Was this translation helpful? Give feedback.
-
For me, a good solution is to have for example Snappy\HtmlToPdf::generate(string $html, array $options = []): StreamInterface
Snappy\UriToPdf::generate(UriInterface $uri, array $options = []): StreamInterface
Snappy\FileToPdf::generate(SplFileInfo $file, array $options = []): StreamInterface All of these are plugged to adapters and there adapters must implements one or more of interfaces Snappy\Backend\HtmlToPdf
Snappy\Backend\UriToPdf
Snappy\Backend\FileToPdf And for example, if you use a tranformer named
|
Beta Was this translation helpful? Give feedback.
-
You said you want to make it more flexible, even with things like SaaS solution ? I would be interested to contribute to the SaaS integration (somekind of backend plugin system ?) |
Beta Was this translation helpful? Give feedback.
-
Ideas sounds good. Is there any news on this? |
Beta Was this translation helpful? Give feedback.
-
Are you sure chrome headless is gonna work also on shared hosting? here is the output:
|
Beta Was this translation helpful? Give feedback.
-
How's the v2 going ? |
Beta Was this translation helpful? Give feedback.
-
Hi guys @alexpozzi @AntoineLelaisant @PedroTroller We have a problem with the version of the pdfs which is generated (1.4) by Wkhtmltopdf. This library does not allow you to generate files in 1.7. |
Beta Was this translation helpful? Give feedback.
-
Hi guys!
We are currently looking forward to rewrite snappy in order to make it more flexible and able to use other backends such as headless chrome, SaaS solutions, etc.
Motivations
Big picture about the new approach
Snappy is currently built on top of two main classes:
Pdf
andImage
. We plan to replace them by a rootSnappy
class that would provide a unified method to generate a pdf from an uri or an html string. The method signature would be something like:Behind the scene, the
Snappy
class would use an adapter pattern to generate the pdf. The adapter will be responsible for actually generating the pdf (or the image).The final usage would be something like:
Adapters
We plan to provide the following adapters:
-
Wkhtmltopdf
(already implemented)-
Wkhtmltoimage
(already implemented)-
Chrome headless
(new)Note for
wkhtmltopdf
: Even if the project is abandoned we will continue to maintain an adapter for it. This should ease the process of migrating from Snappy v1 to Snappy v2.Nevertheless, we will provide and document a way to create your own adapter. Indeed, we want to make it easy to use other tools such as SaaS solutions.
Foreseen Breaking Changes
<=v8.0
. (see: https://www.php.net/supported-versions.php)Knp\Snappy
will be replaced byKnpLabs\Snappy
in order to be consistent with the other KnpLabs FOSS projects.wkhtmltopdf
used to provide this feature but this does not seem to exist on most other tools.Feedbacks
Feel free to comment this discussion if you have any feedbacks or ideas about the new approach. All of these changes are still a plan and we are open to discuss about it. We are looking forward to hear from you!
Beta Was this translation helpful? Give feedback.
All reactions