<?php  
   
   for ( $i=1 ; $i<10 ; $i++ ) {
    $newfile="./".sprintf("%03d",$i) ; 
    $msg = $i."\n";
  
    $file = fopen ($newfile.'.txt', "w"); 
    fwrite($file, $msg); 
    fclose ($file);	  
	  
   $newfiletxt = $newfile.'.txt';  
   $newfileps  = $newfile.'.ps';
   $newfilepng = $newfile.'.png';
   //$syscall1="/usr/local/bin/bg5ps -s 14 -cs 3 -if $newfiletxt -of $newfileps";
   $syscall1="/usr/local/bin/uniprint -out $newfileps -in $newfiletxt -font /usr/local/share/fonts/TrueType/bkai00mp.ttf";
   $output1=`$syscall1`; 
   // delay for check file exists
   $etime=0;
   $chk_file=true;
   while($chk_file) {
	 $etime++;  
     if (file_exists($newfileps)){ $chk_file=false;	}
	 else if($etime>100000){  $chk_file=false;};
    }
   
    
   $syscall_3="/usr/local/bin/convert $newfileps -density 150x150 $newfilepng ";
  // echo $syscall_3;
  // $output1=`$syscall_3`;
   exec("PATH=$PATH:/usr/local/bin;export PATH;$syscall_3");

	 }
	 

?>
