PDFRenderer::render()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 42
rs 8.8571
cc 1
eloc 23
nc 1
nop 2
1
<?php
2
3
namespace raphiz\passwordcards;
4
5
class PDFRenderer
6
{
7
    public static function render($front, $back)
8
    {
9
        // create new PDF document
10
        $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, 'mm', 'A4', true, 'UTF-8', false);
11
12
        // set document information
13
        $pdf->SetAuthor('Raphael Zimmermann');
14
        $pdf->SetTitle('Password Card');
15
        $pdf->SetSubject('Password Card');
16
17
        $pdf->SetPrintHeader(false);
18
        $pdf->SetPrintFooter(false);
19
20
        // add a page
21
        $pdf->AddPage();
22
23
        // Mark the position to fold...
24
        $pdf->Line(95, 10, 95, 13);
25
        $pdf->Line(95, 72, 95, 75);
26
27
        // Add the front svg
28
        $pdf->ImageSVG(
29
            $front, // filename
30
            10, // x
31
            15, // y
32
            '85', // width
33
            '55' // height
34
        );
35
36
        // Add the back svg
37
        $pdf->ImageSVG(
38
            $back, // filename
39
            95, // x
40
            15, // y
41
            '85', // width
42
            '55' // height
43
        );
44
45
46
        //Close and output PDF document
47
        return $pdf->Output('generated.pdf', 'S');
48
    }
49
}
50