By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

Calling pdf creator from php script

P: 1
I currently have a php script for an insurance program where a person chooses the value of a vehicle, length of policy etc. The info is stored in a mysql database on a Linux server and after customer pays, the same script has a routine that writes a pdf policy using fpdf.

Now things changed and there are 4 different types of pdf policies that could print based on variables. I want to write 4 different moduules using php and fpdf to create policies. How do I get the main php script to call up the modules?

Thank you.
Oct 26 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 938
How do you call the existing single module?

Perhaps if you had a class that took care of PDF output you could simply instantiate the class then depending on the output you wanted call the relevant function on that class, this would use the syntax below:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function __autoload($pcClassName)
  3.     {
  4.         require_once '../lib/' . $pcClassName . '.php' ; // change t the path the class definition is stored in
  5.     }
  7. $loPDFObject - new pdfObject() ;
  9. // code to determine which function to call - possibly a switch statement
  10. switch $lnDocType
  11. {
  12. case 1:
  13. $loPDFObject->outputMainDoc() ;
  14. break ;
  15. case 2:
  16. $loPDFObject->outputDoc2() ;
  17. break ;
  18. case 3:
  19. $loPDFObject->outputDoc3() ;
  20. break ;
  21. case 4:
  22. $loPDFObject->outputDoc4() ;
  23. break ;
  24. }
This is partial psuedo code and should give yo some ideas for further developing your own code.

Have a go at solving the problem and post back any further questions remembering to wrap any code in code tags.

Nov 18 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.