Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > note 44111 deleted from ref.pdf by didou
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 27th May 08:05
External User
 
Posts: 1
Default note 44111 deleted from ref.pdf by didou



Note Submitter: arjen at queek dot nl

----

If you prefer a OO-approach to the PDF-functions, you can use this snippet of code (PHP5 only! and does add some overhead). It's just a "start-up", extend/improve as you wish...
You can pass all pdf_* functions to your object and stripping pdf_ of the function name. Plus, you don't have to pass the pdf-resource as the first argument.

For example:
<?php
pdf_show($pdf, $text); // Where $pdf is your pdf-resource
?>

Can become:
<?php
$pdf->show($text); // Where $pdf is your PDF-object
?>

Code:
<?php

class PDF {

private $pdf;

/* public Void __construct(): Constructor */
public function __construct() {
$this->pdf = pdf_new();
}

/* public Mixed __call(): Re-route all function calls to the PHP-functions */
public function __call($function, $arguments) {
// Prepend the pdf resource to the arguments array
array_unshift($arguments, $this->pdf);

// Call the PHP function
return call_user_func_array('pdf_' . $function, $arguments);
}

}

?>
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666