The image generated fine, but I am unable to print it. When I print/print preview..it has a red X.
I tried a few other methods. One is to set a static filename.
eg. imagejpeg($im,"static.jpg",90);
But the browser seemed to be using the old cached copy, so I have to keep refreshing the output page to get the new image to display. Therefore this is not a viable option. Tried using no-cache in the header etc, but it still caches.
Anyone has any ideas?
Code -
// Set the static variables (discussed in steps 2 and 3)
$font_file = $_SERVER['DOCUMENT_ROOT']."/test/fonts/verdana.ttf";
$font_size = 30;
$angle = 0;
$text = "$new_price1";
// The dummy image hack (discussed in step 1)
$im_size = getimagesize("images/design_1a.jpg");
$image_width = $im_size[0];
$image_height = $im_size[1];
$im = imagecreate($image_width, $image_height);
$white = imagecolorallocate($im, 0, 0, 0);
$im2 = imagecreatefromjpeg("images/design_1a.jpg");
imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);
imagedestroy($im2);
// Position the text (discussed in step 3)
$bounding_box = imagettfbbox($font_size, 0, $font_file, $text);
$x_start = $image_width - $bounding_box[2] - $bounding_box[0] - 10;
$y_start = $image_height - 10;
// Write the text to the image
imagettftext($im, $font_size, $angle, $x_start, $y_start, $white, $font_file, $text);
// Create and then destroy the image (discussed in steps 5 and 6)
//header("Content-type: image/jpeg");
imagejpeg($im,"",90);//saves it to that file too
imagedestroy($im);