pdf certificate spans on six pages

pdf certificate spans on six pages

by Maurizio Firmani -
Number of replies: 5
Hi all,
using moodle 1.9.7 with certificate module. I found that the pdf certificate has 6 pages. The first is the certificate and the rest are just empty pages. Of course I need a one page certificate. There must be something wrong in my setup, I guess, but I don't know where the bug is. Do you have any suggestion?

TIA

Maurizio
Average of ratings: -
In reply to Maurizio Firmani

Re: pdf certificate spans on six pages

by Raymond Fürst -
Do you use one of the standard certificate types or a customized one?

Are you using the latest version of the certificate module?
In reply to Raymond Fürst

Re: pdf certificate spans on six pages

by Maurizio Firmani -
Hi Raymond,
I use a customised one. I'll try to use one of the standard and see what happen.

Ok. Tried. The span on six pages occur even with the standard template.

Yes I am using the latest version of the certificate module which I modified to handle correctly scorm grade method set to Learning Object and to set the text a bit lower.

This is the diff file

--- lib.php.orig 2010-07-09 02:12:02.000000000 +0200
+++ lib.php 2010-07-29 16:11:10.000000000 +0200
@@ -932,7 +932,7 @@
global $pdf;
$pdf->setFont("$font", "$style", $size);
$pdf->SetXY( $x, $y);
- $pdf->Cell( 500, 0, "$text", 0, 1, "$align");
+ $pdf->Cell( 500, 120, "$text", 0, 1, "$align");
}

/************************************************************************
@@ -1590,8 +1590,10 @@
$scorm = get_record('scorm', 'id', $cm->instance);
$score = scorm_grade_user($scorm, $userid);
if (($scorm->grademethod % 10) == 0) { // GRADESCOES
- if (!$scorm->maxgrade = count_records_select('scorm_scoes',"scorm='$scorm->id' AND " . sql_isnotempty('scorm_scoes', 'launch', false, true))) {
- return NULL;
+ if ($score < count_records_select('scorm_scoes',"scorm='$scorm->id' AND " . sql_isnotempty('scorm_scoes', 'launch', false, true))) {
+ return NULL;
+ } else {
+ return true;
}
} else {
$return->maxgrade = $scorm->maxgrade;
@@ -1696,4 +1698,4 @@
}
return $status;
}
-?>
\ No newline at end of file
+?>



Maurizio
In reply to Maurizio Firmani

Re: pdf certificate spans on six pages

by Raymond Fürst -
Perhaps you should undo the changes in line 932 in lib.php
The basic function Cell() is defined in /lib/tcpdf/tcpdf.php and uses 0 as a default value for the second parameter.

The parameters 500 and 0 (resp. 120) define the size of the box that tcpdf puts the text into. I'm not sure what unit size the second parameter is measured with. I assume 123 makes the box so big that it automatically casts extra pages.

So you should restore the old value and modify the mod/certificate/mytype/certificate.php if you want to lower the text on paper.
In reply to Raymond Fürst

Re: pdf certificate spans on six pages

by Maurizio Firmani -
You're right! That was the problem. Restoring $pdf->Cell( 500, 0, "$text", 0, 1, "$align"); solved the problem.

Thank you very much!

Maurizio

P.S.
As regarding the changes in the lib.php code to handle correctly the scorm learning object, where should I submit the patch?