When using an alternate theme (Chameleon) the certificate would never print the first time - it would display a single line of text stating an error about the pdf already existing or something. After that, clicking the button shows the certificate without any problem.
I switched from Chameleon back to a standard theme, tested a new certificate, and it worked fine the first time.
Where in the code does the theme need to be modified for a certificate to work correctly the first time?
(Moodle 1.9.5, latest certificate module.)