soulmedia Posted January 26, 2009 Share Posted January 26, 2009 Hi, I have a class that I've written to make a basic PDF report. I want to add the ability to create graphs in these reports, and was wondering about the best way to do it, design-wise. I though it would be good to maybe extend my original class, but for when each graph has been completed, I would need a way of 'cleaning' the extended class of the data I have set, without affecting the base class. My other thought was to create the class 'standalone' and then pass a reference to the PDF object to it, so that I can use the base class's methods and properties. This would mean I could unset() and create a new instance for each graph, so not have to worry about cleaning up. But the disadvantage is that I would have to make much of the base class 'public' in order to get the access that I need. Or should I put the extra code straight into the base class? Many thanks in advance for your advice.. Peter Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/ Share on other sites More sharing options...
cooldude832 Posted January 26, 2009 Share Posted January 26, 2009 What I would do is generate the graphs in its own class and then save them as png and then somehow when you call it to graph you know that temp file name and in your pdf you import that temp file name and then delete it after insertion. Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/#findComment-747071 Share on other sites More sharing options...
soulmedia Posted January 26, 2009 Author Share Posted January 26, 2009 Many thanks for your reply. I would like to be able to do it that way; the problem is I am generating the graphs directly into the PDF rather than as a graphic. I will look into changing to GD, or similar, as it would be a simpler way of doing things. The ability to write the graphs as PDF information did appeal to me though, mainly because of the reduced file sizes in comparison to including graphics. Thanks again, Peter Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/#findComment-747084 Share on other sites More sharing options...
redarrow Posted January 27, 2009 Share Posted January 27, 2009 here you go very easy, the class is there to use and it let you add it to a pdf file. http://www.kidslovepc.com/php-tutorial/php-dynamic-chart-plot.php Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/#findComment-747088 Share on other sites More sharing options...
cooldude832 Posted January 27, 2009 Share Posted January 27, 2009 Did you write your own pdf library or did you download one out there? I know some of em have basic drawing in it which is probably what you are doing? Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/#findComment-747100 Share on other sites More sharing options...
soulmedia Posted January 27, 2009 Author Share Posted January 27, 2009 redarrow: Thanks for your recommendation. The reason I chose to write my own code is that the graph I need to produce is very specialised. I have tried libraries such as JPGraph and found that they wouldn't do what I wanted without further modification, so decided to write my own. cooldude832: I'm using PDFlib; I have written a wrapper class to hide some of the complexities and make report writing quicker. I create the PDF document and instantiate the PDFlib object in the wrapper class. Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/#findComment-747109 Share on other sites More sharing options...
cooldude832 Posted January 27, 2009 Share Posted January 27, 2009 I use R&OS pretty much stock, I don't like the syntax structure to it, but it works very well. My PDFs are basically forms for faxing so there is just a bunch of tables n data Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/#findComment-747141 Share on other sites More sharing options...
soulmedia Posted January 27, 2009 Author Share Posted January 27, 2009 Hi, I decided to go for the 'extend the base class' approach. To get around the 'cleaning up' issue I am using the reflectionClass object to enumerate the properties of the current object and nullify only those variables with a clean() method. Thanks for all your suggestions. Peter Link to comment https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/#findComment-747848 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.