php - dompdf->render(); not working in api class -


i'm having problem when trying render html pdf using dompdf.

i have code placed inside class , after procedure code create pdf of html.

this code have @ moment:

$templatefile = file_get_contents("templates/costreport.htm"); //fill headers $templatefile = str_replace("%dates%",stripslashes($startdate)." - ".stripslashes($enddate),$templatefile);       if ($siteid>0) {     $pdfname = "costreport-".$clientid.".pdf"; } else {     $pdfname = "costreport-".$clientid."-".$siteid.".pdf"; } //insert database //close , output pdf document $pdfname = str_replace("/","-",$pdfname); $pdfname = str_replace("\\","-",$pdfname); //create pdf // unregister yii's autoloader spl_autoload_unregister('my_autoloader'); // register dompdf's autoloader require_once("../system/dompdf/dompdf_config.inc.php"); // register yii's autoloader again spl_autoload_register('my_autoloader'); $dompdf = new dompdf(); $dompdf->set_paper("a4","portrait"); $dompdf->load_html($templatefile); //set_time_limit(240); $dompdf->render(); $pdf = $dompdf->output(); // can write $pdf disk, store in database or stream // folder. file_put_contents('../tmp/'.$clientid.'/'.$pdfname, $pdf);   

the code fails when dompdf->render(); in once take line out code works , file created cant open if hasn't rendered.

i've tried debugging code , made template html valid i'm @ loss now.

the error getting boolen false when run script dompdf->render(); in it.

the problem had piece of code @ top of class.

/set path new dir including dir created             chdir("../tmp/");             $newdirpath = getcwd()."/".$clientid;             //if old invoice ticket pack exists unlink not things confused new pack being created.             if (file_exists(getcwd()."/$clientid_$siteid_costreport.pdf")) {                 unlink(getcwd()."/$clientid_$siteid_costreport.pdf");             }             //setup temp dir             if (!is_dir($newdirpath)) {                 //create new dir if doesn't exist!                 mkdir($newdirpath);             } else {                 //dir exists need empty out first incase there's old stuff in there don't want duplicate data                 //$this->removedirectory($newdirpath,false);             } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -