diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2022-12-07 07:17:21 +0000 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2022-12-07 07:17:21 +0000 |
| commit | 3d8cb20aef2c55cadd38dccc3f51128d7e357ecf (patch) | |
| tree | a144f9afa0c2b2bcb2622f61d89455fd84a85614 /lib/classes/CoursewarePDFCertificate.php | |
| parent | d22c048e14a346feac17aa8983c0b89bf9010490 (diff) | |
Resolve "Erweiterung Courseware: Zertifikate, Erinnerungen und Rücksetzen des Fortschritts"
Closes #1660
Merge request studip/studip!1172
Diffstat (limited to 'lib/classes/CoursewarePDFCertificate.php')
| -rw-r--r-- | lib/classes/CoursewarePDFCertificate.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/classes/CoursewarePDFCertificate.php b/lib/classes/CoursewarePDFCertificate.php new file mode 100644 index 0000000..e3ef02f --- /dev/null +++ b/lib/classes/CoursewarePDFCertificate.php @@ -0,0 +1,40 @@ +<?php + +class CoursewarePDFCertificate extends TCPDF +{ + public function __construct($background = false, $orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8') + { + $this->config = Config::get(); + if ($this->config->getValue('LOAD_EXTERNAL_MEDIA') === 'proxy') { + $this->media_proxy = new MediaProxy(); + } + 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); + } +} |
