Support » Plugin: WP Survey And Quiz Tool » Added TCPDF Support

  • tdxdave



    I have modified the pdf.php to use TCPDF instead of DocRaptor. The pricing for DocRaptor didn’t really scale for the amount of users and certificates we needed to process.

    TCPDF is a little trickier to use as you need to write PHP code to place the elements you want to appear. You can use a PDF as a background if you want to add some style.

    If anyone is interested in this code let me know.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi tdxdave,

    Iยดm really interested in the code. ๐Ÿ™‚

    Hello tdxdave,

    I am also interested in the modifications you made for TCPDF support as I too don’t have any use for the included PDF support. This has been preventing me for quite some time from releasing an exam. If need be, you can get my contact info from my profile.

    Thank you!

    Hi tdxdave

    i am also interested, what are your plans?

    thank you

    I’ll post the code as is, this week. I didn’t have a chance to clean it up. Mainly its a simplification of the pdf.php file.


    This will be very useful for sure ๐Ÿ™‚



    I would also be interested.


    Hi tdxdave

    Any news on that?
    Thank you

    This is the basic code, put the tcpdf code somewhere. I think there is a TCPDF plugin that makes the library available.

    I added some settings into the quiz to give the certificate a title different than the name of the quiz. I hard coded a link to a PDF template for the certificate background. A lot more could be done with this but its the basic idea.

    Here is the code that generates the PDF

    require_once dirname(dirname(__FILE__)).'/tcpdf/tcpdf.php';
    	require_once dirname(dirname(__FILE__)).'/tcpdf/lib/fpdi/fpdi.php';
            $pdf = new FPDI("L",'mm','LETTER', true, 'UTF-8', false);
        $pagecount = $pdf->setSourceFile('certificate-background-002.pdf');
        $tplidx = $pdf->importPage(1, '/MediaBox');
        $size = $pdf->getTemplateSize($tplidx);
            $pdf->setFont("Times", "", 33);
            $pdf->SetXY( 0, 0 );
            $html = '<div><h1 style="margin:-40px 0 0 0;">Certificate of Training</h1>';
            $pdf->writeHTML($html, false, false, false, false, 'C');
            $pdf->setFont("Times", "", 24);
            $html = '<p>'.$personName . '';
            $html .= 'has successfully completed</p>';
            $pdf->writeHTML($html, false, false, false, false, 'C');
            $pdf->setFont("Times", "", 28);
            $cert_name = $quizDetails['settings']['certificate_title'];
            if (!$cert_name || empty($cert_name)) {
                $cert_name = $quizDetails['name'];
            $html = '<h3 style="margin:0;">'. $cert_name .'</h3>';
            $pdf->writeHTML($html, false, false, false, false, 'C');
            $pdf->setFont("Times", "", 24);
    	$html = '<p>on '.$datetaken. '</p></div>';
            $pdf->writeHTML($html, false, false, false, false, 'C');
            $pdf->setFont("Times", "", 12);
            $html = '<table><tr><td width="10%"> </td><td width="30%"><img src="/images/signature3.jpg"></td><td width="10%\
    "> </td><td width="40%"></td><td width="15%"> </td></tr><tr><td></td><td><hr>Signer Name</td><td></td><td><hr>'.$pd\
            $pdf->writeHTML($html, false, false, false, false, 'L');
            $pdf->Output('certificate.pdf', 'I');// open in browser

    Thank you tdxdave. It is very much appreciated!

    Thank you tdxdave.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Added TCPDF Support’ is closed to new replies.