In the view page "ShowInformation.php" I have the code something like this including the omit css style code and other stuff
<?php foreach ($preUser as $value): ?>
Citizen ID : <?php echo $value->cid;?></br>
First Name : <?php echo $value->name;?></br>
...
<?php endforeach; ?>
$preUser is a variable passing from the controller and its from database.
I need to add the download button in that page and generate the PDF with exact the same PHP/HTML/CSS, supporting UTF-8.
Any suggestion ?
WOW I worked but I have my doubts this is the best way?
CI 2.1.3
i'm using html2pdf and it's fine with CI 2+.
it took me sometime to find the right examples for my case but i finally succeeded.
Here's how i did :
1- INSTALL
Get html2pdf at: http://www.html2pdf.fr/en
Copy html2pdf folder into your CI/application/third_party/
*(you'll get something like: application/third_party/html2pdf/html2pdf.class.php)*
2- The controller function to process PDF
3- The view file
Create a template like file in "application/views/path/to/view_tpl.php"
Use placeholders like {myvar} instead of
<?php echo $myvar ?>
Remember! do not include: html,head, body tags !
4. PDF FILE DESTINATION
The pdf can be saved anywhere. Just specify a destination in the controller function (see
$thefullpath
and$previewpath
)Hope it can help !