Using jpg as the full certificate

Using jpg as the full certificate

by Ruth Cheesley -
Number of replies: 10

Hi guys,

I've got a client who has got certificates ready designed, a4 portrait.  Is there any way of using this jpg file as a 'background' and then just putting the date & student name in the appropriate place?

I've tried using it as a border however it does not show at all (white background) presumably because it's not the same size as all the other borders?

Any help gratefully received!

Ruth

Average of ratings: -
In reply to Ruth Cheesley

Re: Using jpg as the full certificate

by Chris Collman -
Picture of Documentation writers

Hi Ruth,

Nice theory, but no.  See ./mod/certificate/lib.php for the border print settings.  Certificate forces a portrait border to be 10, 10, 594, 771 (starts at 10,10 and will force it to be 594 by 771).

Supspect the file.  Did you copy one of the existing fancy borders in /certificate/pix/borders and give it another name and see if that worked?   I took a 800x600 file and decreased it to 300x120 and made another that was 3000x1200 and 3000x2400.  Certificate did it's best to make them fit.

Download one of those standard jpg border files and look at it with the same program you viewed the customer's certificate image.   Is it really a jpg image or a file with a jpg extention that was never properly converted?

Or perhaps you tweaked the portrait code in the /certificate/type/portrait/certificate.php file?   When I make a mistake there, none of the other borders display.

I have made all those mistakes. Hope this helps  Chris

Average of ratings: Useful (1)
In reply to Chris Collman

Re: Using jpg as the full certificate

by Ruth Cheesley -

Hi Chris,

Not sure whether you understood my question.  The client's certificate is a proper jpg image (it's actually a really lovely certificate!) which they were using with another system, that allowed them to just drop the student's name and date of passing onto the image.  I am sure that this system can do this, as it's doing it with the certificate module.

It does not require borders, watermarks or any kind of resizing to be done as it's already done and dusted within the jpg file.

All the other standard borders work just fine, I'm fairly sure the reason why mine does not is because the certificates are 800x1131 px - I have not made changes to the certficate.php other than creating my own 'type' as advised to do so in the tutorial by copying the portrait folder, to avoid overwriting with updates.

What I was asking is can I tell it either to scale to those dimensions (or ideally not scale at all) and then just plop the strings to put the student's name & date of passing onto this image.

Ruth

In reply to Ruth Cheesley

Re: Using jpg as the full certificate

by Chris Collman -
Picture of Documentation writers

Hi Ruth,

That is what I thought you meant and obviously I did a poor job in communicating.  The image should scale.

Of course if you are proofing it as a student and the teacher set "save certificates" to yes, then what ever the first issued certificate to the student looks like, that is what the student is going to see forever. Wild idea but no cigar.  And I do not think it is one of Moodle's famous, remember to refresh the browser issues either.

Very puzzeling. But we will find a solution.

Chris

In reply to Ruth Cheesley

Re: Using jpg as the full certificate

by Raymond Fürst -

If you have your own certificate type, you might modify the corresponding certificate.php:

  • Uncomment the lines beginning with "print_border", "draw_frame" and "print_watermark" to permanently disable borders, lines and watermarks for this type.
  • The following line puts an image directly to the certificate:
    $pdf->Image("$CFG->dirroot/mod/certificate/type/yourtype/yourclients.jng", xcoordinate, ycoordinate, width, height);
    Of course you should move your client's jpg accordingly and apply the correct coordinates and dimensions. I use such a line do print my company logo.
In reply to Raymond Fürst

Re: Using jpg as the full certificate

by Ruth Cheesley -

Thanks for the ideas everyone, will give them a shot and hopefully manage to get it sorted out smile

Ruth

In reply to Ruth Cheesley

Re: Using jpg as the full certificate

by Darren Richards -

Thanks, Raymond for posting the code for placing an image directly into the certificate.

As a novice, I've got a question that is probably very obvious to most.

Where at in the type unicode_landscape/certificate.php file should the code be placed?  I tried placing it under the print_signature line, but got a syntax error in dreamweaver.

I also tried placing it in under the "add text" area.

Thanks so much for your help.

In reply to Darren Richards

Re: Using jpg as the full certificate

by Raymond Fürst -

Both locations you mention are in principle ok for such a line. The script has a beginning section with code that does some formatting, then some lines that initiate the pdf-page-generation-process, and then code that actually puts all the graphical and textual pieces onto the page.

You should consider putting the line with the image quite far to the bottom of the code. The objects are put onto the certificate in the order the lines appear in the script, so if you put your image quite early, it might be covered with a background or border image.

You mention dreamweaver as an editing tool. I am not sure wether dreamweaver is suitable for php code. I use gedit on a linux machine that has php syntax highlighting.

I am not that much of an php programmer, so my code snippet might contain errors. You should replace the fields like "width" and "height" with appropriate numerical values. Check the Image-function in tcpdflib.php for a synopsis with all parameters. Do not forget the ; at the end of the line, and check for quotes and doublequotes.

In reply to Raymond Fürst

Re: Using jpg as the full certificate

by Darren Richards -

Thanks a million for your help.  I actually recopied and pasted you code, and it worked like a charm. I had a mistake in the coding.

I really appreciate your taking time to help.

These forums are great for 'newbies" like me.

Darren

In reply to Ruth Cheesley

Re: Using jpg as the full certificate

by Harvey Arkawy -

I just did it!  Here is how it was accomplished:

I created a new type as described within these forums.

I did a screen dump of my pdf file, saved it as a jpg and copied it to the pix/seals folder.

I scanned in my signature and modified it to include a 2 pt. line under it and added the "Instructor:" text below it.  I then saved it as a png file within the Signatures folder.

I then modified the new type file's certificate.php by reming out most of the cert_printtext lines except for the student's name, class name, certificate date, credit hours and code.

I set the output to print the "seal" (my pdf's jpg) first, then the signature and all of the rest of the text.  I used the location (left from page, down from top, width,height ...) to specify the location of the items to print.

Attached is a shortened version of the type/php file.

I hope this helps anyone/everyone.

In reply to Harvey Arkawy

Re: Using jpg as the full certificate

by Raymond Fürst -

Instead of using the background file as a "seal", I would print the background file directly to the certificate. I use the following line to dump my company logo onto the certificate:

$pdf->Image("$CFG->dirroot/mod/certificate/pix/companylogo.png", 590, 425, 120, 50);

You should use a similar line for your complete background image (and move your image out of the seals-subfolder one level up).

Usually, all signatures and all seals have the same size (signatures and seals might differ). If you have one "seal" that covers the whole paper, then it will not work properly on other certificate types that expect just a small seal. As a seal, a teacher might select an other seal as a background.

On my certificates, I do not need any seals, so I copied all the signatures into the seal folder, deleted the old seals and use the seal as a second signature. Now I can choose different combinations of left signature and right signature.