I am working on setting up an on the fly business card generator and I am having some issues!
For some reason I cannot center my text. Here is my code:
$image_width = 600;
$x_name = (($image_width - strlen($name))/2);
$x_address = (($image_width - (strlen($address_line)))/2);
$x_contact = (($image_width - strlen($contact_line))/2);
imagettftext($jpg_image, 20, 0, 300, 220, $black, $font_path, $name);
imagettftext($jpg_image, 16, 0, $x_address, 300, $white, $font_path, $address_line);
imagettftext($jpg_image, 16, 0, $x_contact, 325, $white, $font_path, $contact_line);
imagejpeg($jpg_image);
Where X is the left margin. All my variables are working fine. But this what I am getting:
http://www.fgbmfamerica.org/business-card-preview.php?first_name=First&last_name=Last&address=Address&city=Anywhere&state=TN&postal=55555&phone=555-555-3340&
[email protected]
I am not sure what I am doing wrong but any help would be appreciated!
Thank you!