Certificate (add-on)

 
 
Picture of Tiffany Morgan
Centering custom text field
 

Hi All I am trying to find a way to center the custom text field on the landscape certificate.

So far here is what I have tried and the results (I post all this with the caveat that I am not a php coder):

Problem: The code as is will allow a br tag to break the text across two lines, but does not center the text.

 

Attempt 1:Added html centering tags to the field within Moodle itself

Result: No change--allows a br tag to break the text across two lines, but does not center the text.

 

Attempt 2: In the certificate.php file I removed

cert_printtext(150, 400, '', '', '', '', '');

$pdf->SetLeftMargin(130); $pdf->WriteHTML($customtext);

 

from the very bottom of the page (Approx line 130).

Result: The text will now center, but now a br code does not allow the text to break across two lines

 

Attempt 3: Reverted to original code first, then added the bolded line (surrounding text added for just for context--approx line is 120) cert_printtext(150, 400, 'C', '', '', '', '');

$pdf->SetLeftMargin(130);

$pdf->WriteHTML($customtext);

Result: No change

 

Attempt 4: removed $pdf->SetLeftMargin(130);

Result: text printed way left aligned

 

Attempt 5: reverted back to original code, and then changed line to $pdf->WriteHTML('<div style="text-align: center;">' . $customtext . '</div>');

Result: no change

 

 

Any other ideas are greatly welcomed smile

 
Average of ratings: -
Picture of Shantanu Sikdar
Re: Centering custom text field
 

Hi Tiffany!

Hope you’re doing well.  Let me share your problem and try my hands on in offering a solution.

May I please know the version of Moodle that you’re using currently?

If its Moodle 2.3 or above,  you need to follow the path shown below:

certificate_print_text($pdf, $custx, $custy, 'C', 'Helvetica', null, 13, $certificate->customtext);

where:-

$custx is the co-ordinate for x-axix (set the value accordingly)

$custy is the co-ordinate for y-axix (set the value accordingly)

C will align the text to the centre.

Helvetica the font face.

Null is the font style(bold, italics, underline)

13 is the font-szie

$certificate->customtext is the certificate custom text field value.

It’s our pleasure to help you and I hope this’ll be of your help. Please feel free to get back to us for further reference.

Thanks and Regards

Shan

DualCube

 
Average of ratings: -