5
I am trying to print online certificates dynamically filled with PHP. The code I’m using is:
class Certificado
{
    public $nome_para_certificado = '';
    public $modelo_de_certificado = '';
    function __construct($nome)
    {
        $this->nome_para_certificado = $nome;
    }
    public function gerar() 
    {
        header("Content-Type: image/jpeg");
        $texto = 'Certificamos que ' . $this->nome_para_certificado . ' participou do Evento nos dias 21, 22 e 23 de setembro de 2014 na Universidade Federal da Paraíba - UFPB';
        $img = imagecreatefromjpeg($this->modelo_de_certificado);
        $preto = imagecolorallocate($img, 0, 0, 0);
        $font_path = 'http://meu-site.com/custom/TravelingTypewriter.ttf';
        imagettftext($img, 50, 0, 10, 20, $preto, $font_path, $texto);
        // imagestring($img, 5, 300, 400, $texto, $preto);
        imagejpeg($img);
        imagedestroy($img);
    }
}
When I use imagestring I can print the text right but with the imagettftext it’s not working out.
I need to use the imagettftext to modify font size and type as well.


William, thank you very much! Your tips have helped me a lot to solve the problem. A hug.
– David Coelho
I think I did it right. Check it out? Hug.
– David Coelho