Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i generate pdf reports using symfony2?

Tags:

symfony

I have created an examanition module which provides the report card to the user as an HTML (twig) format. Now I want the user should be able to save the report card as pdf. I have added a button as Save ReportCard and I want to write the code in my controller to generate this pdf file with same content as of the html. I googled and found these links:

  1. PDF Lib 8
  2. Generate PDFs with PHP

These links where great but I couldnt get how can i use them in symfony2. I am new to symfony2 and Php. Can anyonw help me here with the same.

like image 296
ScoRpion Avatar asked Nov 29 '22 09:11

ScoRpion


1 Answers

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

i often use this for tricky html5 projects. with the javascript support from wkhtml2pdf you can add svg's and other pretty things to your pdf...

like image 99
Flask Avatar answered Dec 22 '22 03:12

Flask