function TextFileToImage($infile, $font_size, $out_dir, $extra_line_space = 0) { global $OUTPUT_HTML_FILENAME; global $VERBOSE; global $FORCE_GEN; $utf_file = NULL; if (!file_exists($out_dir)) { mkdir($out_dir); } ///// check time if ($FORCE_GEN == false && file_exists($infile)) { $infile_time = filemtime($infile); $output_html_path = CreateFullPath($out_dir, $OUTPUT_HTML_FILENAME); if (file_exists($output_html_path)) { $html_gen_time = filemtime($output_html_path); if ($html_gen_time > $infile_time) { if ($VERBOSE) { printf("skipping old file %s\n", $infile); } return; } } //big5 to unicode /* $utf_file = tempnam("/tmp", "texttoimageutf_"); system("iconv -sc -f BIG5 -t UTF8 < ".$infile." > ".$utf_file); $infile = $utf_file; */ } // clear output dir $output_dir_files = CreateFullPath($out_dir, "*"); system("\\rm -rf {$output_dir_files}"); $sn = 0; $linenum = 1; if (file_exists($infile) && ($fp = fopen($infile, "rt"))) { while (!feof($fp)) { $buf = fgets($fp, 4096); $outfile = sprintf("img_%d.png", $sn); $outfile = CreateFullPath($out_dir, $outfile); TextToImage($buf, $font_size, $outfile, $extra_line_space, $linenum); $sn++; $linenum++; } fclose($fp); } /////// link by html /////// $buf = CreateFullPath($out_dir, $OUTPUT_HTML_FILENAME); //$buf = sprintf("%s/code.html", $out_dir); $fp = fopen($buf, "wt"); if ($fp) { fprintf($fp, "<html>\n"); //fprintf($fp, "File uploaded at %s<br/><br/>", date ("Y/n/j H:i:s.", filemtime($infile))); fprintf($fp, "Conversion time: %s<br/><br/>", date("Y/n/j H:i:s.", time())); for ($k = 0; $k < $sn; $k++) { fprintf($fp, "<img src=\"img_%d.png\"/>\n", $k); fprintf($fp, "<br/>"); } fprintf($fp, "</html>\n"); fclose($fp); } else { printf("cannot open %s\n", $buf); } if ($utf_file != NULL) { unlink($utf_file); } }
<div class="signature-details"> Confirmed by: <?php echo $_POST['fullname']; ?> <br /> Date: <?php echo $_POST['signDate']; ?> </div> <div class="client-signature"> <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/text-to-img.php'; //TextToImage ($text, $separate_line_after_chars=40,$size=24,$rotate=0,$padding=2,$transparent=true, $color=array('red'=>0,'grn'=>0,'blu'=>0), $bg_color=array('red'=>255,'grn'=>255,'blu'=>255)) TextToImage($_POST['fullname'], 40, 50, 0, 20, false); ?> <div class="signature-img"> <img src="<?php echo SITEROOT; ?> /<?php echo $data['ref']; ?> /signature.png" style="vertical-align: bottom;" alt="signature"> </div> </div> <?php $html = ob_get_contents(); //pre($html);