How can I generate PDF reports using symfony2?

I created an exam module that provides a report card to the user in the form of HTML (twig). Now I want the user to be able to save the report card in pdf format. I added a button as Save report card, and I want to write code in my controller in order to generate this pdf file with the same contents as html. I googled and found these links:

These links are where great, but I could not get how I can use them in symfony2. I am new to symfony2 and php. Can anyone help me here with the same.

+4
source share
3 answers

Another solution that is more painless than creating an entire custom PDF would be to create print css. then get the whole DOM with lib, like wkhtml2pdf. There is also a lib from knplabs https://github.com/KnpLabs/snappy and a kit https://github.com/KnpLabs/KnpSnappyBundle

I often use this for complex html5 projects. with javascript support from wkhtml2pdf you can add svg and other beautiful things to your pdf ...

+14
source

A large library with many TCPDF features. WhiteOctoberTCPDFBundle or IoTcpdfBundle are some of the packages created by the community in this library. You can find several packages to help you create PDF files in knpbundles .

+6
source

I spent many hours looking for the appropriate library. The main goal was to generate PDFs as easily as possible without positioning coordinates, special functions for the feed, and that ...

The best match I've found so far was: https://github.com/psliwa/PdfBundle

... which has a symfony suite and a GitHub entry contains tons of examples. Great library.

+4
source

Source: https://habr.com/ru/post/1411991/


All Articles