HTML2PDF Conversion with getOpt functions

Hi All,

A beginner to php. I am using the HTML2PDF libaries. I also wrote the getOpt function as below :

[php]

<?php require_once("/home/christiaan/NetBeansProjects/EvosatHtml2Pdf/classes/Converter.php"); class evo_html2pdf { Public function getOpt($options, $hasArgs, $argv) { foreach($argv as $arg) { if($hasArgs) { $opt = explode("=", $arg); if($opt[0] == $options) { return $opt[1]; } } else if($arg==$options) { return true; } } return false; } } $converter = new Converter(); $converter->ConvertHTML($html2pdf, $argv); ?>

[/php]

Also I created the class that will use the conversions and the getOpt function and connect them all as below :[php]

<?php /** * Description of Converter * * @author christiaan */ require_once('/home/christiaan/NetBeansProjects/EvosatHtml2Pdf/lib/html2pdf_v4.03/html2pdf.class.php'); require_once('/home/christiaan/NetBeansProjects/EvosatHtml2Pdf/evo_html2pdf.php'); class Converter { public function ConvertHTML($html2pdf,$argv) { $optionParser = new evo_html2pdf(); $cliArgs = $argv; //Supply help if($optionParser->getOpt("-h",false,$cliArgs)) { // Print help displayHelp(); exit(0); } //Supply all variables if (!defined('VERBOSE')) define('VERBOSE', $optionParser->getOpt("-v",false,$cliArgs)); if (!defined('HELP')) define('HELP', $optionParser->getOpt("-h",false,$cliArgs)); if (!defined('SOURCE')) define('SOURCE', $optionParser->getOpt("-s",true,$cliArgs)); if (!defined('TARGET')) define('TARGET', $optionParser->getOpt("-t",true,$cliArgs)); //Get the HTML ob_start(); $content = ob_get_clean(); //Convert the HTML try { $html2pdf = new HTML2PDF(); $html2pdf->WriteHTML(); $html2pdf->Output('','F'); echo("File created"); } catch(HTML2PDF_exception $e) { echo $e; exit; } } function displayHelp() { print("-v=VERBOSE \r\n"); print("-s=SOURCE \r\n"); print("-t=TARGET \r\n"); } } ?>[/php]

The only issue is that when passing the arguments for $html2pdf->WriteHTML(); and $html2pdf->Output(’’,‘F’);,
how would I connect “-s” and “-t” with the above? So suppose $html2pdf->WriteHTML(); would connect to “-s” as it would use the .html file as the source and “-t” will use $html2pdf->Output(’’,‘F’); as it is the target file.

Sponsor our Newsletter | Privacy Policy | Terms of Service