How to make automated certificate

<?php

$yourname = “TARUYUYIU”;
$date = “09 Dec 2013”;
$pos = “2nd”;

$image = imagecreatefrompng(‘certificate.png’);
imagealphablending($image, true);

$red = imagecolorallocate($image, 150,0, 0);

// imagefttext(“Image”, “Font Size”, “Rotate Text”, “Left Position”, “Top Position”, “Font Color”, “Font Name”, “Text To Print”);

imagefttext($image, 30, 0, 40, 154, $red, ‘mono.ttf’, $yourname);
imagefttext($image, 20, 0, 312, 206, $red, ‘mono.ttf’, $date);
imagefttext($image, 20, 0, 82, 256, $red, ‘mono.ttf’, $pos);

/* If you want to display the file in browser */

/*
header(‘Content-type: image/png’);
ImagePng($image);
imagedestroy($image);
*/

/* if you want to save the file in the web server */

/*
$filename = ‘certificate_aadarsh.png’;
ImagePng($image, $filename);
imagedestroy($image);
*/

/* If you wnat the user to save the file */

/*
$filename = ‘certificate_aadarsh.png’;
ImagePng($image,$filename);

header(‘Pragma: public’);
header(‘Cache-Control: public, no-cache’);
header(‘Content-Type: application/octet-stream’);
header(‘Content-Length: ‘ . filesize($filename));
header(‘Content-Disposition: attachment; filename=”‘ . basename($filename) . ‘”‘);
header(‘Content-Transfer-Encoding: binary’);
readfile($filename);

imagedestroy($image);

*/

$filename = ‘certificate_aadarsh.png’;
ImagePng($image, $filename);
imagedestroy($image);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s