aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/CoursewarePDFCertificate.php
blob: ca6e704c27b221960218f44a56ebe0ed85dc8344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

class CoursewarePDFCertificate extends TCPDF
{
    protected $background;

    public function __construct($background = false, $orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8')
    {
        parent::__construct($orientation, $unit, $format, $unicode, $encoding, false);

        if ($background) {
            $fileRef = FileRef::find($background);
            $this->background = $fileRef->file->getPath();
        } else {
            $this->background = $GLOBALS['STUDIP_BASE_PATH'] . '/public/assets/images/pdf/pdf_default_background.jpg';
        }

        $this->setDefaults();
    }

    public function Header()
    {
        $bMargin = $this->getBreakMargin();
        $auto_page_break = $this->AutoPageBreak;
        $this->SetAutoPageBreak(false, 0);
        $this->Image($this->background, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
        $this->setFont('helvetica', 'B', 50);
        $this->Cell(0, 160, 'Z E R T I F I K A T', 0, false, 'C', 0, '', 0, false, 'T', 'M');
        $this->SetAutoPageBreak($auto_page_break, $bMargin);
        $this->setPageMark();
    }

    private function setDefaults()
    {
        $this->SetTopMargin(110);
        $this->SetLeftMargin(20);
        $this->SetRightMargin(20);
    }
}