Customise certificates
  • 05 Apr 2022
  • 3 minutes to read

Customise certificates


Article Summary

The certificate module creates PDF certificates for learners on the course, and certificates are completely customisable. You can add borders, watermarks, seals, and even show grade information.

Upload images 

It is possible to upload border, watermark, seal, and signature images to be used in a certificate.

  1. Select Quick-access menu > Plugins > Activity modules > Certificate.
  2. Click Upload.
  3. Select the image file using the file picker and add the image to the area you want to store this.
  4. Select Save changes.

Selecting the certificate font

For certificates with embedded fonts you can choose the font to use for the site.

  1. Select Quick-access menu > Plugins > Activity modules > Certificate.
  2. Select the font to use for Serif and Sans-serif fonts. 
  3. Select Save changes.

Create a customised certificate format

It is possible to create your own custom certificate type. Your customised certificate appears on the list with the standard certificate types.

  1. Choose the certificate/type folder with the size/orientation you desire, copy and paste it in the certificate/type folder, and give the copied folder a new name. For example copy the /type/letter_landscape folder and rename it 'mycertificate'.
  2. Open the certificate/lang/en_utf8/certificate.php file and add the name of your new folder type. Following the above example, you would add: $string['typemycertificate'] = 'My New Certificate';

Now, when you add a certificate to a course, your new type should appear on the dropdown list as "My New Certificate".

You will need to include the correct string (as demonstrated above) otherwise you may receive an error message that will appear as though the code is broken. You should also note that if you upgrade the certificate module then files may disappear and you will need to set this up again.

Changing printed text

There are different lang strings in the certificate/lang/en_utf8/certificate.php file for each certificate type, so be sure to change the correct one for the type you are using. For example, if you want to customise the text for the landscape type, you can change these lines in the above mentioned lang file.

This is what the default looks like:

$string['titlelandscape'] = 'CERTIFICATE OF ACHIEVEMENT';

$string['introlandscape'] = 'This is to certify that';

$string['statementlandscape'] = 'has successfully completed the course';

Here is a customised example :

$string['statementlandscape'] = 'has successfully passed the final exam';

Adding a new line of text

Open the certificate/lang/en_utf8/certificate.php file and add your new lang string giving it a unique name, e.g.

$string['mynewtext'] = 'This is what I want to print on the certificate';

Open the file for your certificate type, e.g. certificate/type/mycertificate/certificate.php. At the bottom of the page below '// Add Text' is the code that prints--you guessed it--text on the certificate. Find the current line below which you would like your new text to be printed. For example, if you want your text to print below the course name, find the line:

cert_printtext(170, 330, 'C', 'Helvetica', '', 20, utf8_decode($classname));

Add a new line below that to print your new text using the name you gave your new lang string like this:

cert_printtext(170, 350, 'C', 'Helvetica', '', 20, utf8_decode(get_string('mynewtext', 'certificate')));

Make sure you add a string to the language file called mynewtext. The above line of code gets that string.

You can adjust the placement over from the left by increasing or decreasing the '170' number. You can adjust the placement down on the page by increasing or decreasing the '350' number. Changing 'C' to 'L' or 'R' will print on the left or right side. For different fonts, see the totara/lib/fpdf font folder for non-unicode types, and the totara/lib/tcpdf/fonts folder for unicode types, for available fonts.

For unicode certificates, using more than one font is not recommended since the entire font gets embedded in the certificate which increases the certificate file size.

After the font name, you can add:

  • B for bold
  • I for italic
  • U for underline

Changing the '10' number will change the font size.

cert_printtext(170, 350, 'C', 'Times', , 10, utf8_decode($USER→idnumber));

You can add a hard coded line of text. For example, a signature title block line:

cert_printtext(150, 490, 'L', 'Times', , 10, utf8_decode('Keegan Jones, Director'));

Add your string to the PDF image

You can add your own custom string to the PDF print section. We wanted to add 'These continuing credits are from our organisation' below the title of the course. We used the landscape certificate type.

We added the string to the language file.

$string(ceusfromus) = 'These continuing credits are from our organisation';

In the type folder's certificate.php file, in the PDF area near the end of the file, we put the following line:

cert_printtext(170, 380, 'C', 'Helvetica', '', 16, utf8_decode (get_string('ceusfromus', 'certificate')));

Next steps

© Copyright 2024 Totara Learning Solutions. All rights reserved. Some content originally obtained via GPLv3 license and continues to be available under GPLv3. All other content is the sole copyright of Totara Learning Solutions. 


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.