Symfony 5 KnpSnappyBundle & wkhtmltopdf Setup and Example(with an explanation of possible errors)
Snappy is a PHP wrapper for the wkhtmltopdf conversion utility.
Snappy works with wkhtmltopdf, so you need to install on your system wkhtmltopdf. I installed it on my Mac via brew as below.
Install command;
brew install --cask wkhtmltopdf
Check for configuration where it’s installed;
which wkhtmltopdf
Installation
With composer, require:
composer require knplabs/knp-snappy-bundle
Configuration
knp_snappy.yaml;
.env;
.env for docker;
Example
If you have error as below;
Warning: Blocked access to file: Worked in 0.12.5
Usage of many https link in html causes “Failed to load about:blank, with network status code 301 and http status code 0 — Protocol “about” is unknown”
Fixed with this option:
$this->pdf->setOption('enable-local-file-access', true);
— — —
My YouTube Channel;
mail@yusufbiberoglu.com
My Udemy Course;
Symfony application using Google OAuth for authentication. When a user signs in through Google, our system will check if the user already exists in our database. If not, it will create a new user account. Once authenticated, either as a new or existing user, our application will generate a JSON Web Token (JWT). Built on the API Platform.
If you want a detailed explanation, please purchase my Udemy course.
Discount Coupon: AD25A625CB8976085C88
Here’s my articles which might interest you;
Testing Benford’s Law in Symfony 5, Php Framework
Symfony 5 PhpSpreadsheet (Creating Excel File)
Symfony user checker(check for login of users with status = active) Easy way
Symfony 5 Contact Form with Mailer and Mime component(MailerInterface)