Welcome Guest, Not a member yet? Register   Sign In
Need design advice for generating PDF files
#1

[eluser]Unknown[/eluser]
I'm building an app to generate certificates for students who complete training classes. The current app that's being replaced does this using Javascript + HTML; I'd like to do it with CodeIgniter + PDF using the FPDF library. I already have a nice modular MVC design that accesses a (makeshift) database, gets the data needed for the certificate, and prints it to the screen. Now I need to turn that into PDF functionality.

My questions are, is it reasonable to implement this PDF code in a file outside the controller, and if so how would you do it? I thought of putting the code in a view that doesn't actually display anything, then calling it with
Code:
$this->load->view( 'pdf_view', true );
but that seems to go against the principle of least astonishment.

This probably has an easy solution, but unfortunately I'm a nub. It'll certainly work whether the design is decoupled or not, but if it's possible I'd like to make it easy on the next person who reads this code. Thanks in advance for your help.
#2

[eluser]drewbee[/eluser]
I would create the entire pdf file in the html counter part in the view, then when loading the view return it as a string and pass this new string to the pdf generator with the required data.




Theme © iAndrew 2016 - Forum software by © MyBB