WordPress.org

Ready to get started?Download WordPress

Forums

WP Survey And Quiz Tool
Added TCPDF Support (11 posts)

  1. tdxdave
    Member
    Posted 1 year ago #

    Hi,

    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.

    http://wordpress.org/extend/plugins/wp-survey-and-quiz-tool/

  2. eduticle
    Member
    Posted 1 year ago #

    Hi tdxdave,

    I´m really interested in the code. :)

  3. jmoorewv
    Member
    Posted 1 year ago #

    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!

  4. stickFinger
    Member
    Posted 1 year ago #

    Hi tdxdave

    i am also interested, what are your plans?

    thank you

  5. tdxdave
    Member
    Posted 1 year ago #

    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.

  6. stickFinger
    Member
    Posted 1 year ago #

    @tdxdave

    This will be very useful for sure :-)

    thx

  7. mgisys
    Member
    Posted 1 year ago #

    @tdxdave

    I would also be interested.

    Thx

  8. stickFinger
    Member
    Posted 1 year ago #

    Hi tdxdave

    Any news on that?
    Thank you

  9. tdxdave
    Member
    Posted 1 year ago #

    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');
        $pdf->AddPage();
        $size = $pdf->getTemplateSize($tplidx);
        $pdf->useTemplate($tplidx,0,0);
            $pdf->setPrintHeader(false);
            $pdf->setPrintFooter(false);
            $pdf->SetMargins(15,0);
            $pdf->SetTextColor(0,0,0);
            $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\
    fTemplate.'</td><td></td></tr></table>';
            $pdf->writeHTML($html, false, false, false, false, 'L');
            $pdf->Output('certificate.pdf', 'I');// open in browser
  10. jmoorewv
    Member
    Posted 1 year ago #

    Thank you tdxdave. It is very much appreciated!

  11. mgisys
    Member
    Posted 1 year ago #

    Thank you tdxdave.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.