SturaPDF   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 33
rs 10
c 3
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Footer() 0 12 1
A Header() 0 13 1
1
<?php
2
/*
3
 * Copyright (C) 2020  Jan Böhmer
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published
7
 * by the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
namespace App\Services\PDF;
20
21
use DateTime;
22
use IntlDateFormatter;
23
use TCPDF;
24
25
/**
26
 * A TCPDF class configured to create a PDF document with StuRa header.
27
 */
28
class SturaPDF extends TCPDF
29
{
30
    public function Header()
31
    {
32
        $image_file = dirname(__DIR__, 3).'/assets/StuRa.png';
33
34
        //$image_file = 'C:\Users\janhb\Documents\Projekte\PHP\stura\assets\StuRa.png';
35
36
        $this->Image($image_file, 5, 5, 210, 0, 'png', 'https://stura.uni-jena.de');
37
38
        $this->SetFont('helvetica', '', 9);
39
        $this->setY(35);
40
        $this->writeHTMLCell(0, 0, 100, 50, '<h2>Studierendenrat</h2>');
41
        $this->writeHTMLCell(0, 0, 145, 55, 'Carl-Zeiss-Straße 3');
42
        $this->writeHTMLCell(0, 0, 145, 60, '07747 Jena');
43
44
        // Title
45
        //$this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
46
        //$this->writeHTML($image_file);
47
    }
48
49
    public function Footer()
50
    {
51
        // Position at 15 mm from bottom
52
        $this->SetY(-15);
53
54
        $this->SetFont('helvetica', 'I', 8);
55
        // Page number
56
        $this->Cell(0, 10, 'Seite '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'L');
57
58
        $formatter = new IntlDateFormatter('de-DE', IntlDateFormatter::SHORT, IntlDateFormatter::MEDIUM);
59
60
        $this->Cell(0, 10, 'Erzeugt '.$formatter->format(new DateTime()), 0, false, 'R');
61
    }
62
}
63