How can I create some images and normal html code mixed?
And when I print that php-page to the printer, images will be printed also.
One good example is bill form (with normal html format) and barcode 128C image at bottom of html page.
I try like this
if ($HTTP_POST_VARS['submit']) {
function EAN13barcode($code) {
$lw = 2; $hi = $lw*50; $hi/=2;
$Lencode = array('0001101','0011001','0010011','0111101','0100011',
'0110001','0101111','0111011','0110111','0001011');
$Lenecode = array('0100111','0110011','0011011','0100001','0011101',
'0111001','0000101','0010001','0001001','0010111');
$Rencode = array('1110010','1100110','1101100','1000010','1011100',
'1001110','1010000','1000100','1001000','1110100');
$Parity = array('111111','110100','110010','110001','101100',
'100110','100011','101010','101001','100101');
$starts = '101'; $center = '01010';
/* EAN-13 Must be 12 digits, we compute the checksum. */
if ( strlen($code) != 12 ) { die("EAN-13 Must be 12 digits."); }
/* Compute the EAN-13 Checksum digit */
$ncode = $code;
$even = 0; $odd = 0;
for ($x=0;$x<12;$x++) {
if ($x % 2) { $odd += $ncode[$x]; } else { $even += $ncode[$x]; }
}
$code.=(10 - (($odd * 3 + $even) % 10)) % 10;
/* Create the bar encoding using a binary string */
$bars=$starts;
$fixing=$Parity[$code[0]];
for($x=1;$x<7;$x++) {
{
if ($fixing[$x-1]=='0') { $bars.=$Lenecode[$code[$x]]; }
else { $bars.=$Lencode[$code[$x]]; }
}
}
$bars.=$center;
for($x=7;$x<13;$x++) {
$bars.=$Rencode[$code[$x]];
}
$bars.=$starts;
/* Generate the Barcode Image */
$img = ImageCreate($lw*95+30,$hi+30);
$fg = ImageColorAllocate($img, 0, 0, 0);
$bg = ImageColorAllocate($img, 255, 255, 255);
ImageFilledRectangle($img, 0, 0, $lw*95+30, $hi+30, $bg);
for ($x=0;$x=92)) { $sh=6; }
if (($x>=46) && ($x<50)) { $sh=6; }
if ($bars[$x] == '1') { $color = $fg; } else { $color = $bg; }
ImageFilledRectangle($img, ($x*$lw)+15,5,($x+1)*$lw+14,$hi+5+$sh,$color);
}
/* Add the Human Readable Label */
ImageString($img,5,2,$hi+5,$code[0],$fg);
for ($x=0;$x<6;$x++) {
ImageString($img,5,$lw*(13+$x*7)-2,$hi+5,$code[$x+1],$fg);
ImageString($img,5,$lw*(53+$x*7)+10,$hi+5,$code[$x+7],$fg);
}
/* Output the Header and Content. */
header("Content-Type: image/png");
ImagePNG($img);
Imagedestroy($img);
}
EAN13barcode($_POST['barcode']);
}
?>
<html>
<head>
<title>Barcode</title>
</head>
<body>
<form action="<?=$PHP_SELF?>" name="barcode" method="post" enctype="multipart/form-data">
Enter barcode number (without last checknumber): <input type="text" name="barcode" size="12" maxlength="12">
<script language="JavaScript" type="text/javascript">
<!--
document.barcode.barcode.focus();
// -->
</script>
<input type="submit" name="submit" value="Create barcode">
</form>
</body>
</html>
but that not work. Print preview doesn't show barcode image.
LukeSW