Browse code

Update

Benjamin Roth authored on20/03/2023 16:19:16
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,107 @@
1
+<?php
2
+
3
+/**
4
+ * viabook platform for Contao Open Source CMS
5
+ *
6
+ * Copyright (C) 2012-2014 eSalesMedia
7
+ *
8
+ * @package    eSM_viabook
9
+ * @link       http://www.esales-media.de
10
+ * @license    commercial
11
+ *
12
+ * @author     Benjamin Roth <benjamin@esales-media.de>
13
+ */
14
+
15
+
16
+/**
17
+ * Namespace
18
+ */
19
+namespace eSM_isotope_custom\Pdf;
20
+
21
+
22
+/**
23
+ * Class ViabookDocuments
24
+ *
25
+ * Generates pdf documents
26
+ * @copyright  eSales Media 2014
27
+ * @author     Benjamin Roth <benjamin@esales-media.de> 
28
+ * @package    eSM_viabook
29
+ */
30
+abstract class Document extends \Controller
31
+{
32
+
33
+	/**
34
+	 * ESMPDF
35
+	 * @var ESMPDF
36
+	 */
37
+	protected $objPdf;
38
+
39
+	public function __construct($strTcpdfClass='\eSM_isotope_custom\Pdf\ESMPDF')
40
+	{
41
+		parent::__construct();
42
+		if (!class_exists($strTcpdfClass))
43
+		{
44
+			throw new \Exception('Class "'.$strTcpdfClass.'" does not exist');
45
+		}
46
+		$this->objPdf = $this->pdfInit($strTcpdfClass);
47
+	}
48
+
49
+
50
+	protected function pdfInit($strTcpdfClass)
51
+	{
52
+		// TCPDF configuration
53
+		$l['a_meta_dir'] = 'ltr';
54
+		$l['a_meta_charset'] = $GLOBALS['TL_CONFIG']['characterSet'];
55
+		$l['a_meta_language'] = $GLOBALS['TL_LANGUAGE'];
56
+		$l['w_page'] = 'page';
57
+
58
+		// Create new PDF document
59
+		$pdf = new $strTcpdfClass(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
60
+
61
+		// Set document information
62
+		$pdf->SetCreator(PDF_CREATOR);
63
+		$pdf->SetAuthor(PDF_AUTHOR);
64
+		$pdf->SetTitle("Expertise");
65
+		$pdf->SetSubject("Produkt-Expertise - Baden-Badener Weinhaus GmbH");
66
+		$pdf->SetKeywords("Expertise, Wein, Baden-Baden");
67
+		$pdf->setViewerPreferences(array('PrintScaling'=>'None'));
68
+
69
+		// Prevent font subsetting (huge speed improvement)
70
+		$pdf->setFontSubsetting(false);
71
+
72
+		// Remove default header/footer
73
+		$pdf->setPrintHeader(false);
74
+		$pdf->setPrintFooter(false);
75
+
76
+		// Set margins
77
+		$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
78
+		$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
79
+
80
+		// Reset cell padding
81
+		$pdf->setCellPaddings(0,0,0,0);
82
+
83
+		// Set auto page breaks
84
+		$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
85
+
86
+		// Set image scale factor
87
+		$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
88
+
89
+		// Set some language-dependent strings
90
+		$pdf->setLanguageArray($l);
91
+
92
+		return $pdf;
93
+	}
94
+
95
+	private function &pdfObj()
96
+	{
97
+		return $this->objPdf;
98
+	}
99
+
100
+	public function pdf()
101
+	{
102
+		return $this->pdfObj();
103
+	}
104
+
105
+	abstract public function generate();
106
+
107
+}
0 108
\ No newline at end of file