Wednesday, October 10, 2012

HTML TO PDF IN YII FRAMEWORK

Download the files using below link to generate html to PDF files.
Download HTML2PDF

Next: Extract it and you will get following folders and files Folder _class _tcpdf_5.0.002 locale Files html2pdf.class Next: Create Folder inside extension of yiiframework as "tcpdf". Copy above files and folders and paste into "tcpdf" folder. Next: html2pdf.class has contains "HTML2PDF" class. I changed html2pdf.class file name as "HTML2PDF" (For my use) Call this view from controller.
Ex. In reportview.php Ex: In reportviewcontent.php I configured pdf page in reportview.php and put content separately in reportviewcontent.php

6 comments:

  1. in Chrome it gives the following error:
    "Failed to load PDF Document"

    in Firefox its working perfecty, when downloaded , can't open in adobe reader...

    any suggesion ??

    ReplyDelete
    Replies
    1. Now I changed render to renderPartial in controller. Now its working in chrome and firebox

      Delete
  2. Hi balu

    thank you i like this post.it is very useful to me....

    ReplyDelete
  3. TCPDF ERROR: Some data has already been output, can't send PDF file

    why is this ??
    any solution ??

    ReplyDelete
    Replies
    1. use renderPartial() method to avoid this error

      Delete