Forum Moderators: coopster
$PageWidth = 600;
$font = '/Library/Fonts/Chalkboard.ttf'; /* on a Mac */
$fontSize = 12;
$CheckText = "All the text I want to print.";
$tmpfname = tempnam("/tmp", ".png");
$FileHandle = fopen($tmpfname, "w");
$NumberofLines = Count(explode("
", $CheckText));
$PageLength = ($fontSize * $NumberofLines);
$PrintImage = imagecreate($PageWidth, $PageLength);
$black = imagecolorallocate($PrintImage, 0, 0, 0);
imagettftext($PrintImage, $fontSize, 0, 10, 5, $black, $font, $CheckText);
$FinalResulToPrint = imagepng($PrintImage);
fwrite($FileHandle, $FinalResulToPrint);
$FilePathOfFileReadyToPrint = realpath($tmpfname);
/* The Print Command */
if(!exec("lp -d TSP600__STR_T_U001_ $FilePathOfFileReadyToPrint", $PrintResult)){$PrintStatus = false;}
then I do the fclose and imagedestroy.
Thanks
Earbite