View Full Version : print paper size

05-24-2011, 11:22 PM
Hey guys i have a challenge on my hands and i can't seem to settle it...

see i made a car dealership script for my body and he needs to print out window stickers(window regular paper with car info)

so i made a litle script that echo's the info(from MySQL DB) on to an image.

all good.But when it comes to print a get a super small image on a paper..lol

so i re did the background image to fit printer size...but man is it big and i cant get the info on it..

is there a way to make a page with a background image that prints ok...

like this

05-25-2011, 12:13 AM
Find out what DPI you are printing at and render the image at the correct size (http://uk.answers.yahoo.com/question/index?qid=20081121144421AAlDwp1). That info is for A4, so if you are using a different paper size you'll need to find the pixels for that.

05-25-2011, 12:26 AM
so how wold this work?lets say i want it at

300 dpi (print) = 2480 X 3508 pixels

how can i make a php page with the info to print on it?

cant make a table of 2480 * 3508 and put the pic in background?

05-25-2011, 12:31 AM
Show your code that generates the image and someone can help you out.

05-25-2011, 12:35 AM
the image is already done.

i need to but it as background a make the code on top of it to echo the car' s info..

see this is the image.


05-25-2011, 06:08 AM
Load your image in to GD using imagecreatefromgif() (http://php.net/imagecreatefromgif), then write the text to the image using imagettftext() (http://php.net/imagettftext), and finally write out the result using imagegif() (http://php.net/imagegif).

05-25-2011, 11:12 AM
wow..lol ok i will look it up.thx!

05-25-2011, 11:25 AM
how im i going to add all my echo's with mysql with this?and ow do i specify were to put the image and txt??

// Définition du content-type
header('Content-Type: image/png');

// Création de l'image
$im = imagecreatetruecolor(400, 30);

// Création de quelques couleurs
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// Le texte à dessiner
$text = 'Test...';
// Remplacez le chemin par votre propre chemin de police
$font = 'arial.ttf';

// Ajout d'ombres au texte
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Ajout du texte
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Utiliser imagepng() donnera un texte plus claire,
// comparé à l'utilisation de la fonction imagejpeg()