Diferencia entre revisiones de «Personalizar certificado»

De MoodleDocs
m (tidy up)
(tidy up)
 
(No se muestran 15 ediciones intermedias del mismo usuario)
Línea 3: Línea 3:


[[Módulo certificado|Certificado]] es un [[Complementos|complemento]] y puede personalizarse por el administrador más allá de la descarga estándar. En general.  
[[Módulo certificado|Certificado]] es un [[Complementos|complemento]] y puede personalizarse por el administrador más allá de la descarga estándar. En general.  
 
#This can be done by uploading additional image types through the site administration menu. Or by uploading images into one of the certificate/pix folders.
#The displayed text can be changed by customizing the language in site administration.  Or directly editing the /certificate/lang file. 
#The location of certificate images and text can be change by creating/editing a certificate type's code.


==Certificate examples==
#Esto puede hacerse al subir tipos de imágenes adicionales mediante el menú de administración del sitio, o al subir imágenes hacia una de las carpetas de certificate/pix.
<gallery caption="Certificate examples - click on any to enlarge" widths="200px" heights="100px" perrow="6">
#El texto mostrado puede cambiarse al [[Personalizar el idioma]] en la administración del sitio, o editando directamente el archivo /certificate/lang file. 
Image:Certificate 27 plain.png|Shows no options selected, standard title, course name, user name and words.
#La localización de las imágenes y texto del certificado puede cambiarse al crear/editar el código para un tipo de certificado.
Image:Certificate 1.gif|Fancy border, signature line, seal, code
 
Image:Certificate 27 manyoptions.png|Shows many text and images selected, signature, seal, watermark, code, grade, teachers name, custom text and border
==Ejemplos de certificados==
Image:Certificate199 example lines.png|Lines, signature, seal, watermark, code, grade, outcomes, custom text
<gallery caption="Ejemplos de Certificados - haga click en una imagen para agrandarla" widths="200px" heights="100px" perrow="6">
Image:Certificate 27 plain.png|Se muestra sin opciones seleccionadas, título estándar, nombre del curso, nombre_del_usuario y palabras.
Image:Certificate 1.gif|Borde sofisticado, línea de Firma, sello y código
Image:Certificate 27 manyoptions.png|Muestra muchos textos e imágenes seleccionadas, firma, sello, sello-de-agua, código, calificación, nombre del profesor, calificación, [[Competencias]], texto personalizado
Image:Certificate199 example lines.png|Líneas, firma, sello, sello-de-agua, código, calificación, [[Competencias]], texto personalizado
.
.
Image:Certificate199 example creative.png|Uploaded border, signature, watermark and seal
Image:Certificate199 example creative.png|Borde subido, firma, sello-de-agua y sello
Image:Certificate 27 customcode.png |Custom everything, new certificate type, with new text strings, new text and image positions, plus uploadd watermark, seal, signature and border.  
Image:Certificate 27 customcode.png |Todo personalizado, nuevo tipo de certificado, con nuevas cadenas de texto, nuevas posiciones para texto y para imágenes, más sello-de-agua, fima y borde  subidos.  
</gallery>
</gallery>


==Personalización==
==Personalización==
The certificate code is located in the /mod/certificate folder.   There are sub-folders for backup, db, lang (holds language sub-folders), type (holds standard certificate types, each in their own sub-folder) and pix. The pix folder holds the sub-folders for the default borders, seals, signatures and watermarks. These will be used at the time of  installation and become the default standard choices, after that they will not be used.   
El código del certificado está localizado en la carpeta  /mod/certificate. Existen subcarpetas para backup (respaldo), db (base_de_datos), lang (contiene sub-.carpetas para los diferentes [[Idiomas]]), type (contiene los tipos estándar de certificados, cad uno en su propia sub-carpeta) y pix (imágenes). La carpeta pix contiene las sub-carpetas para los borde (orillas) por defecto, los sellos, las firmas y los sellos-de-agua. Estos se usarán al momento de la instalación y se volverán las opciones estándar, pero después ya no se usarán más.   


===Añadir imágenes===
===Añadir imágenes===
[[Image:Certificate199 example creative.png|thumb|Creative customized example]] The easiest way to customize your certificate is for the site administrator to add your own JPG or PNG images for  borders, seals, signatures and watermarks to the default images found at the time of installation. The system administrator should go to the site administration block, Plugins>Activities>Certificate>Upload images.
[[Image:Certificate199 example creative.png|thumb|Ejemplo personalizado creativo]] La forma más fácil para personalizar su certificado es que el adminitrador del sitio  añada sus propias imágenes  JPG o PNG para las orillas (bordes), sellos, firmas y sellos-de-agua a las imágenes por defecto al momento de la instalación. El administrador del sistema debe de ir al bloque de Administración del sitio >  Plugins > Actividades > Certificado > Subir imágenes.


Make sure your new files are the same size as the standard images. For example, the standard signature file is 150x31 pixels. If the signature file is a different size, you may need to modify the code line. The same will be true for seals, borders and watermarks.The sample seals are 80x80 pixels in size.
Asegúrese de que sus nuevos archivos sean del mismo tamaño que las imágenes estándar. Por ejemplo, la firma estándar es de 150 pixeles por 31 pixeles. Si el archivo de su firma es de tamaño diferente, Usted puede necesitar modificar la línea del código que lo describe. Lo mismo aplica para los bordes (orillas), sellos y sellos-de-agua. Los sellos de ejemplo miden 80x80 pixeles, los bordes (orillas) de ejemplo miden 800x604 o 1024x831 pixeles y los sellos-de-agua de ejemplo miden 386x468 o 380x380 pixeles.


In the creative example, a custom border, watermark, signature and seal were uploaded. All were sized and in the same file format as the one supplied with the initial certificate install.
En el ejemplo creativo, se subieron un borde personalizado, sello-de agua personalizado, firma y sello personalizados. Todos eran del mismo tamaño y en el mismo formato de archivo del que venía en la instalación inicial del certificado.


===Personalizar el formato (formulario)===
===Personalización del formato===
[[Image:Certificate_27_customcode.png|thumb|New type with new strings, new positions]] You will need to be able to edit your Moodle code to create a custom format.   It is a good idea to create your own custom certificate type, that will appear on a list along with the standard certificates types. You will know which is your custom certificate type and it will survive when you upgrade. Here is how:
[[Image:Certificate_27_customcode.png|thumb|New type with new strings, new positions]] Usted necesitará poder editar su código Moodle para crear un formato personalizado. Es una buena idea el crear su propio tipo de certificado personalizado, el cual aparecerá en una lista junto con los tipos estándar de certificados. Usted sabrá fácilmente cual es su tipo de certificado personalizado y sobrevivirá cuando Usted haga una [[Actualización]] de plugins. Aquí se describe como hacerlo:


1.  Choose the one of the certificate/type folders, copy and paste it in the certificate/type folder. Give the copied folder a new name.  For example copy the /type/letter_non_embedded folder and rename it 'mycertificate'.  
1.  Elija una de las carpetas de certificate/type; cópiela y péguela en la carpeta de certificate/type, pero dándole un nombre diferente. Por ejemplo, copie la carpeta /type/letter_non_embedded y renómbrela a 'micertificado'.  


2.  Open the certificate/lang/en/certificate.php file and add the name of your new folder type. Following the above example, you would add:
2.  Abra el archivo certificate/lang/en/certificate.php y añádale el nombre de su nuevo tipo de carpeta. Siguiendo el ejemplo de arriba, Usted añadiría:


:$string['typemycertificate'] = 'My New Certificate';
:$string['typemicertificado'] = 'Mi Nuevo Certificado';


Now, when you add a certificate to a course, your new type will appear on the drop down list as "My New Certificate".  
Ahora, cuando Usted añada un certificado a un curso, aparecerá su nuevo tipo en la lista del menú desplegable como "Mi Nuevo Certificado".  


:''Tip:'' You should add the proper string as shown in step 2 above or you may receive an error message and it will appear as if the code is brokenAnd remember if you update your certificate module that this file may be erased with a new version.  
:''Sugerencia:'' Usted debe de añadir la cadena de texto apropiada como se muestar en el paso 2 superior, o Usted recibirá un mensaje de  error y aparecerá como si el código del programa estuviera roto. Y recuerde que si actualiza su módulo de certificado, este archivo puede borrarse por una nueva versión.  
: ''Tip:'' The sections below give examples of how to change text and image position in a certificate type file. It also covers how to create a new text string in the certificate lang file.
: ''Sugerencia:'' Las secciones inferiores dan ejemplos de como cambiar las posiciones de imágenes y el texto en un archivo de tipo de certificado. Tambien cubren el como crear una nueva cadena de caracteres de texto dentro del archivo certificate lang.


===Ejemplo de código para modificación de  texto y posición del texto===
===Ejemplos de código para modificación del texto y la posición del texto===
Changing the location of text is done by using code to set the x,y position on the page. The "x" is the distance from the left margin and the "y" is the distance from the topHere are some examples which set the position in the same place:
El cambiar la localización del texto se hace al usar el código para configurar la posición x,y sobre la página. La "x" es la distancia desde el margen izquierdo y la "y" es la distancia desde la parte superior. Todos los archivos de código de certificados comienzan por definir los puntos x,y para varias cadenas de texto o imágenes.
:certificate_print_text($pdf, 28, 183, 'C', 'Times', 'B', 20, get_string('certifymoodle', 'certificate')); //This fixes the start of the text at 28,183.


:certificate_print_text($pdf, $x, $y + 55, 'C', 'Times', 'I', 20, get_string('certifymoodle', 'certificate')); // This uses the x string (which is $x= 28) and adds 55 to the y string (which was $y=128).
Aquí hay algnos ejemplos que configuran la posición en el mismo lugar:
:certificate_print_text($pdf, 28, 183, 'C', 'Times', 'B', 20, get_string('certifymoodle', 'certificate')); //Esto fija el inicio del texto en 28,183.


:certificate_print_text($pdf, $certx, $certy, 'C', 'Times', ' ', 20, get_string('certifymoodle', 'certificate')); //This uses new string definitions that were added to top of the in both Landscape and Portraits sections.
:certificate_print_text($pdf, $x, $y + 55, 'C', 'Times', 'I', 20, get_string('certifymoodle', 'certificate')); // Esto usa la cadena de caracteres x (la cual es $x= 28) y le añade 55 a la cadena de texto y (la cual era $y=128).


In the above examples we centered the text, used the Times font, used bold, italic and none and kept the font size to 20.   
:certificate_print_text($pdf, $certx, $certy, 'C', 'Times', ' ', 20, get_string('certifymoodle', 'certificate'));  /Esto usa nuevas definiciones de cadenas de texto que fueron añadidas a la parte superior de las secciones para ambos estilos Landscape (Paisaje) y Portrait (Retrato).   


We also created a new text string called certifymoodle.  In the /certifcate/lang/certificate.php file we copied the $string['certify'] = 'This is to certify that'; string line, pasted it underneath the original and changed it to read $string['certifymoodle'] = 'This is to say that';
En los ejemplos de arriba, centramos el texto, se uso el tipo de letra (''font'') Times, '''negritas''', ''cursivas'' y nada y se mantuvo el tamaño del tipo de letra en 20. 


Tambien creamos una nueva cadena de caracteres llamada certifymoodle.  En el archivo /certifcate/lang/en/certificate.php copiamos la línea de la cadena de texto $string['certify'] = 'Esto es para certificar que (''This is to certify that'')';, la pegamos debajo de la línea original y la cambiamos para que se leyera $string['certifymoodle'] = 'Esto hace constar que (''This is to say that'')';  Vea la sección inferior para más ejemplos acerca de como cambiar el texto.
:''Sugerencia:'' ¿No cambia el texto?  Usted tendrá que ir a las configuraciones del [[Idioma]] en la administración del sitio y desactivar la caché. Recuerde que esto alentará los tiempos de carga de páginas para todos los usuarios, así que deberá regresarlo a como estaba en cuanto acabe y funcione.


====Ejemplo de código para modificación de posición de imagen====
====Ejemplos de código para modificar la posición de la imagen====


We will change the signature position that is found in the type/letter_non_embedded/certificate.php file when we generate a pdf in landscape mode.  There are at least 2 ways to change the code. Say we want to move it to the left to the 100 position from 130 and up to the 435 line from the 440 line.
We will change the signature position that is found in the type/letter_non_embedded/certificate.php file when we generate a pdf in landscape mode.  There are at least 2 ways to change the code. Say we want to move it to the left to the 100 position from 130 and up to the 435 line from the 440 line.
Línea 72: Línea 74:




====Ajustar la tyransparencia de una imagen====
====Ajustar la transparencia de una imagen====
It is possible to put in a strong image as a watermark and adjust the transparency setting when the PDF is created.  Look for the SetAlpha code in front of a print element. For example infront of the "print_watermark.." line, you will see $pdf_SetAlpha(0.1);  It is currently set to .1, the .3 in our example is less transparent.
It is possible to put in a strong image as a watermark and adjust the transparency setting when the PDF is created.  Look for the SetAlpha code in front of a print element. For example infront of the "print_watermark.." line, you will see $pdf_SetAlpha(0.1);  It is currently set to .1, the .3 in our example is less transparent.


Línea 92: Línea 94:
:$string['statement'] = 'has successfully passed the final exam';
:$string['statement'] = 'has successfully passed the final exam';


===Añadir una Línea Nueva de Texto===
===Añadir una nueva línea de texto===
You have created a couple of custom certificate types.  In these certificates you want some new words to appear.  There are basically 2 choices, you can have it look up a new string, or hard code the words in the certificate type instead of looking for a string.   
You have created a couple of custom certificate types.  In these certificates you want some new words to appear.  There are basically 2 choices, you can have it look up a new string, or hard code the words in the certificate type instead of looking for a string.   


Línea 113: Línea 115:
:cert_printtext($pdf, $sigx, $sigy+30,'', 'Helvetica', 'B', 10, 'Martin Dougiamas, Lead Developer');
:cert_printtext($pdf, $sigx, $sigy+30,'', 'Helvetica', 'B', 10, 'Martin Dougiamas, Lead Developer');


===Adding a second page===
===Añadir una segunda página===
After you have created your first page (or copied an existing page), add this bit of code:
After you have created your first page (or copied an existing page), add this bit of code:


Línea 120: Línea 122:
Then you in the code for the second page. You can create a certificate with as many pages as you want.
Then you in the code for the second page. You can create a certificate with as many pages as you want.


==Cambios en Nov 2011 ==
==Cambios en Noviembre 2011==
[https://github.com/PukunuiAustralia/moodle-mod_certificate PukunuiAustralia / moodle-mod_certificate] version 2011110107 is the basis for these comments.  There maybe earlier versions which are different.
[https://github.com/PukunuiAustralia/moodle-mod_certificate PukunuiAustralia / moodle-mod_certificate] version 2011110107 is the basis for these comments.  There maybe earlier versions which are different.
*Standard types of certificates.  There are 4 standard certificate types based upon paper size and if the fonts are embedded or non-embedded in the pdf documents.  The orientation of landscape or portrait is located within each of these types.  This is different from the 1.9.x versions.
*Standard types of certificates.  There are 4 standard certificate types based upon paper size and if the fonts are embedded or non-embedded in the pdf documents.  The orientation of landscape or portrait is located within each of these types.  This is different from the 1.9.x versions.
Línea 126: Línea 128:


==Sugerencias y Trucos==
==Sugerencias y Trucos==
*Start with one of the existing certificate types, copy it and modify it.  
*Comience con uno de los tipos de certificados existentes, cópielo y modifíquelo.  
*Try your customized code on a non production site, such as a local host.
*Pruebe su código personalizado en un sitio que no sea de producción real, como por ejemplo en una PC local.
*In Administration>>Server set debugging to maximum (to show any coding error messages).
*En Administración >> Servidor configure depuración (''debugging'') al máximo (para mostrar cualquier mensaje de error del código).
*While you can leave a php file open in edit mode, you must save the file before your changes become active.
*While you can leave a php file open in edit mode, you must save the file before your changes become active.
*Make code changes one at a time, test and then backup after each successful change. For example,after adding a new string to the certificate lang file), go to your course page and click on a certificate to see if it appears on the list.
*Make code changes one at a time, test and then backup after each successful change. For example,after adding a new string to the certificate lang file), go to your course page and click on a certificate to see if it appears on the list.
Línea 135: Línea 137:
*Certificate icon location-If you are using your own theme you have to put the icon.gif inside a folder called certificate and put in your mod folder image.  For example, if your theme uses custom icons, you must put a certificate folder with the certificate icon.gif in it under your theme/pix/mod folder.
*Certificate icon location-If you are using your own theme you have to put the icon.gif inside a folder called certificate and put in your mod folder image.  For example, if your theme uses custom icons, you must put a certificate folder with the certificate icon.gif in it under your theme/pix/mod folder.
*Consider editing you language pack rather than the /certificate/lang/en/certificate.php file.  You can do this through the Settings > Site administration >Language > Language customization menu. Look for mod/certificate.php.  Then when you update your certificate and it's language,it will keep your changes for the standard strings.
*Consider editing you language pack rather than the /certificate/lang/en/certificate.php file.  You can do this through the Settings > Site administration >Language > Language customization menu. Look for mod/certificate.php.  Then when you update your certificate and it's language,it will keep your changes for the standard strings.
*You can use a graphics program to edit the empty center space in a 'border' image to create a certificate 'background' that contains larger images, more images and multiple signature lines - without having to edit code.  This is useful if a series of courses are all going to need the same basic certificate layout - just select the correct 'border image' under Design options and be done.
*Use a topic section heading as the certificate title. See [http://moodle.org/mod/forum/discuss.php?d=193170#p842551 in the certificate forum] for a code tweak.
*Use a topic section heading as the certificate title. See [http://moodle.org/mod/forum/discuss.php?d=193170#p842551 in the certificate forum] for a code tweak.
*Your image is stretching?  Add some white space to either side of your canvas.  For example add white space to create the same width/height ratio as defined by the wmarkw and wmarkh code variables.


==Vea también==
==Vea también==

Revisión actual - 19:19 21 mar 2016

Moodle 2.x

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Certificado es un complemento y puede personalizarse por el administrador más allá de la descarga estándar. En general.

  1. Esto puede hacerse al subir tipos de imágenes adicionales mediante el menú de administración del sitio, o al subir imágenes hacia una de las carpetas de certificate/pix.
  2. El texto mostrado puede cambiarse al Personalizar el idioma en la administración del sitio, o editando directamente el archivo /certificate/lang file.
  3. La localización de las imágenes y texto del certificado puede cambiarse al crear/editar el código para un tipo de certificado.

Ejemplos de certificados

Personalización

El código del certificado está localizado en la carpeta /mod/certificate. Existen subcarpetas para backup (respaldo), db (base_de_datos), lang (contiene sub-.carpetas para los diferentes Idiomas), type (contiene los tipos estándar de certificados, cad uno en su propia sub-carpeta) y pix (imágenes). La carpeta pix contiene las sub-carpetas para los borde (orillas) por defecto, los sellos, las firmas y los sellos-de-agua. Estos se usarán al momento de la instalación y se volverán las opciones estándar, pero después ya no se usarán más.

Añadir imágenes

Ejemplo personalizado creativo

La forma más fácil para personalizar su certificado es que el adminitrador del sitio añada sus propias imágenes JPG o PNG para las orillas (bordes), sellos, firmas y sellos-de-agua a las imágenes por defecto al momento de la instalación. El administrador del sistema debe de ir al bloque de Administración del sitio > Plugins > Actividades > Certificado > Subir imágenes.

Asegúrese de que sus nuevos archivos sean del mismo tamaño que las imágenes estándar. Por ejemplo, la firma estándar es de 150 pixeles por 31 pixeles. Si el archivo de su firma es de tamaño diferente, Usted puede necesitar modificar la línea del código que lo describe. Lo mismo aplica para los bordes (orillas), sellos y sellos-de-agua. Los sellos de ejemplo miden 80x80 pixeles, los bordes (orillas) de ejemplo miden 800x604 o 1024x831 pixeles y los sellos-de-agua de ejemplo miden 386x468 o 380x380 pixeles.

En el ejemplo creativo, se subieron un borde personalizado, sello-de agua personalizado, firma y sello personalizados. Todos eran del mismo tamaño y en el mismo formato de archivo del que venía en la instalación inicial del certificado.

Personalización del formato

New type with new strings, new positions

Usted necesitará poder editar su código Moodle para crear un formato personalizado. Es una buena idea el crear su propio tipo de certificado personalizado, el cual aparecerá en una lista junto con los tipos estándar de certificados. Usted sabrá fácilmente cual es su tipo de certificado personalizado y sobrevivirá cuando Usted haga una Actualización de plugins. Aquí se describe como hacerlo:

1. Elija una de las carpetas de certificate/type; cópiela y péguela en la carpeta de certificate/type, pero dándole un nombre diferente. Por ejemplo, copie la carpeta /type/letter_non_embedded y renómbrela a 'micertificado'.

2. Abra el archivo certificate/lang/en/certificate.php y añádale el nombre de su nuevo tipo de carpeta. Siguiendo el ejemplo de arriba, Usted añadiría:

$string['typemicertificado'] = 'Mi Nuevo Certificado';

Ahora, cuando Usted añada un certificado a un curso, aparecerá su nuevo tipo en la lista del menú desplegable como "Mi Nuevo Certificado".

Sugerencia: Usted debe de añadir la cadena de texto apropiada como se muestar en el paso 2 superior, o Usted recibirá un mensaje de error y aparecerá como si el código del programa estuviera roto. Y recuerde que si actualiza su módulo de certificado, este archivo puede borrarse por una nueva versión.
Sugerencia: Las secciones inferiores dan ejemplos de como cambiar las posiciones de imágenes y el texto en un archivo de tipo de certificado. Tambien cubren el como crear una nueva cadena de caracteres de texto dentro del archivo certificate lang.

Ejemplos de código para modificación del texto y la posición del texto

El cambiar la localización del texto se hace al usar el código para configurar la posición x,y sobre la página. La "x" es la distancia desde el margen izquierdo y la "y" es la distancia desde la parte superior. Todos los archivos de código de certificados comienzan por definir los puntos x,y para varias cadenas de texto o imágenes.

Aquí hay algnos ejemplos que configuran la posición en el mismo lugar:

certificate_print_text($pdf, 28, 183, 'C', 'Times', 'B', 20, get_string('certifymoodle', 'certificate')); //Esto fija el inicio del texto en 28,183.
certificate_print_text($pdf, $x, $y + 55, 'C', 'Times', 'I', 20, get_string('certifymoodle', 'certificate')); // Esto usa la cadena de caracteres x (la cual es $x= 28) y le añade 55 a la cadena de texto y (la cual era $y=128).
certificate_print_text($pdf, $certx, $certy, 'C', 'Times', ' ', 20, get_string('certifymoodle', 'certificate')); /Esto usa nuevas definiciones de cadenas de texto que fueron añadidas a la parte superior de las secciones para ambos estilos Landscape (Paisaje) y Portrait (Retrato).

En los ejemplos de arriba, centramos el texto, se uso el tipo de letra (font) Times, negritas, cursivas y nada y se mantuvo el tamaño del tipo de letra en 20.

Tambien creamos una nueva cadena de caracteres llamada certifymoodle. En el archivo /certifcate/lang/en/certificate.php copiamos la línea de la cadena de texto $string['certify'] = 'Esto es para certificar que (This is to certify that)';, la pegamos debajo de la línea original y la cambiamos para que se leyera $string['certifymoodle'] = 'Esto hace constar que (This is to say that)'; Vea la sección inferior para más ejemplos acerca de como cambiar el texto.

Sugerencia: ¿No cambia el texto? Usted tendrá que ir a las configuraciones del Idioma en la administración del sitio y desactivar la caché. Recuerde que esto alentará los tiempos de carga de páginas para todos los usuarios, así que deberá regresarlo a como estaba en cuanto acabe y funcione.

Ejemplos de código para modificar la posición de la imagen

We will change the signature position that is found in the type/letter_non_embedded/certificate.php file when we generate a pdf in landscape mode. There are at least 2 ways to change the code. Say we want to move it to the left to the 100 position from 130 and up to the 435 line from the 440 line.

  • Near the top of the file, you should notice there are a set of variables for "Landscape" which are followed by another set for "Portrait". We can overrule some of the landscape and portrait codes the $sigx and $sigy position variables, so they read $sigx = 100 and $sigy = 435 .
    • Alternatively, we can overrule some of the landscape and portrait codes, in this case the signature block. In the "// Add images and lines" section we see the code that actually prints in the position by using the landscape and portrait variables:
print_signature($pdf, $certificate, $sigx, $sigy, , );

By changing the variables to fix numbers it will not matter if the teacher selects landscape or portrait mode for this custom type. For example:

print_signature($pdf, $certificate, 100, 435, , );

If others have not added a standard signature line, you might want to fix it to a certain size. For example, you want the image to print 150px by 75px.

print_signature($pdf, $certificate, $sigx, $sigy, '150', '75');

This should give you a good idea about how to change the position of other images.


Ajustar la transparencia de una imagen

It is possible to put in a strong image as a watermark and adjust the transparency setting when the PDF is created. Look for the SetAlpha code in front of a print element. For example infront of the "print_watermark.." line, you will see $pdf_SetAlpha(0.1); It is currently set to .1, the .3 in our example is less transparent.

Tip: In older version of certificate, the watermark image itself was dimmed before it was placed in the folder. If you had a custom watermark, this is the way it was done. You can change the SetAlpha in the code to 1 and it should appear as it did in previous version of certificate.

Cambiar el texto impreso

There are two ways to change the language strings. A best practice is to customize your language pack via site administration. You will find the certificate.php in the mod group. If you use the method below, when you update all your certificate files, then your changes will not be saved.

You can edit the language file found in the certificate folder, such as certificate/lang/en/certificate.php if you are not worried about losing you changes. Lets say you want to change the words at the top of all certificates on your site.

Find the default strings:

$string['title'] = 'CERTIFICATE OF ACHIEVEMENT';
$string['intro'] = 'This is to certify that';
$string['statement'] = 'has completed the course';

Change them to read (for example):

$string['title'] = 'DIP0LOMA';
$string['intro'] = 'I am proud to state that';
$string['statement'] = 'has successfully passed the final exam';

Añadir una nueva línea de texto

You have created a couple of custom certificate types. In these certificates you want some new words to appear. There are basically 2 choices, you can have it look up a new string, or hard code the words in the certificate type instead of looking for a string.

  • Add new string method.
    • Open the certificate/lang/en/certificate.php file and add your new string giving it a unique name.
$string['mynewtext'] = 'This is what I want to print on the certificate';
    • Open the file for your certificate type and change the string reference. For example, go to certificate/type/mycertificate/certificate.php. Near the end of the file find "// Add Text". This is the area 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($pdf, $x, $y, 'C', 'Helvetica', , 30, get_string('title', 'certificate'));


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

cert_printtext($pdf, $x, $y+25, 'C', 'Helvetica', 'B', 10, get_string('mynewtext', 'certificate'));

Quick review. We want the string mynewtext to start on the $x position from the left, on the $y+25 line, and the line should be center aligned (C, L, R or ' '), in Helvetica type, in bold, with a font size of 10.


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

cert_printtext($pdf, $sigx, $sigy+30,, 'Helvetica', 'B', 10, 'Martin Dougiamas, Lead Developer');

Añadir una segunda página

After you have created your first page (or copied an existing page), add this bit of code:

$pdf->AddPage();

Then you in the code for the second page. You can create a certificate with as many pages as you want.

Cambios en Noviembre 2011

PukunuiAustralia / moodle-mod_certificate version 2011110107 is the basis for these comments. There maybe earlier versions which are different.

  • Standard types of certificates. There are 4 standard certificate types based upon paper size and if the fonts are embedded or non-embedded in the pdf documents. The orientation of landscape or portrait is located within each of these types. This is different from the 1.9.x versions.
  • The code for printing strings has changed. While similar to the pre 2.0, be careful.

Sugerencias y Trucos

  • Comience con uno de los tipos de certificados existentes, cópielo y modifíquelo.
  • Pruebe su código personalizado en un sitio que no sea de producción real, como por ejemplo en una PC local.
  • En Administración >> Servidor configure depuración (debugging) al máximo (para mostrar cualquier mensaje de error del código).
  • While you can leave a php file open in edit mode, you must save the file before your changes become active.
  • Make code changes one at a time, test and then backup after each successful change. For example,after adding a new string to the certificate lang file), go to your course page and click on a certificate to see if it appears on the list.
  • If you broke the code you may get a blank screen for a certificate.
    • So it might be a good idea to make a backup of each successful change before starting the next change. For example, after the 3rd code change, save certificate.php as certificate3.txt.
  • Certificate icon location-If you are using your own theme you have to put the icon.gif inside a folder called certificate and put in your mod folder image. For example, if your theme uses custom icons, you must put a certificate folder with the certificate icon.gif in it under your theme/pix/mod folder.
  • Consider editing you language pack rather than the /certificate/lang/en/certificate.php file. You can do this through the Settings > Site administration >Language > Language customization menu. Look for mod/certificate.php. Then when you update your certificate and it's language,it will keep your changes for the standard strings.
  • You can use a graphics program to edit the empty center space in a 'border' image to create a certificate 'background' that contains larger images, more images and multiple signature lines - without having to edit code. This is useful if a series of courses are all going to need the same basic certificate layout - just select the correct 'border image' under Design options and be done.
  • Use a topic section heading as the certificate title. See in the certificate forum for a code tweak.
  • Your image is stretching? Add some white space to either side of your canvas. For example add white space to create the same width/height ratio as defined by the wmarkw and wmarkh code variables.

Vea también