in packages, PHP, symfony

Snappy – How to create PDF with Symfony and twig

Long time ago I use FPDF to create PDF Documents and reports. FPDF allows you to define a PDF using blocks. This process is slow as you can not reuse any of the views you already code in html or your frontend components.

For a long time there has been a new player wkhtmltopdfwkhtmltopdf is a headless chrome port that generate PDF’s or Images from a website and you can use it in Symfony with Snappy bundle.

Examples

Downloading a page as a PDF

From HTML

My favourite

More info at: https://github.com/KnpLabs/snappy

Working with wkhtmltopdf can be tricky if you have any comments, tricks or issues please comment.

Write a Comment

Comment