1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Custom PDF class extention for Header and Footer Definitions
|
5
|
*
|
6
|
* @author office@interpid.eu
|
7
|
*
|
8
|
*/
|
9
|
// JQ Sky added lines for the 6 x hdr and footer variables and also the code in the header and footer functions
|
10
|
|
11
|
namespace Interpid\PdfExamples;
|
12
|
|
13
|
use Interpid\PdfLib\Pdf;
|
14
|
use Interpid\PdfLib\Multicell;
|
15
|
|
16
|
class MyPdf extends Pdf
|
17
|
{
|
18
|
|
19
|
// protected $headerSource = "header.txt";
|
20
|
|
21
|
/**
|
22
|
* Custom Header
|
23
|
*
|
24
|
* @see Pdf::Header()
|
25
|
*/
|
26
|
|
27
|
// JQ Sky added lines for the 6 x hdr and footer variable @@@@@@@@@@@ STARTS @@@@@@@@@@@@@
|
28
|
|
29
|
private $headerTxt;
|
30
|
private $address;
|
31
|
private $registration;
|
32
|
private $telephone;
|
33
|
private $email;
|
34
|
private $website;
|
35
|
|
36
|
public function __construct($headerTxt, $address, $registration, $telephone, $email, $website ) {
|
37
|
$this->headerTxt = $headerTxt;
|
38
|
$this->address = $address;
|
39
|
$this->registration = $registration;
|
40
|
$this->telephone = $telephone;
|
41
|
$this->email = $email;
|
42
|
$this->website = $website;
|
43
|
parent::__construct();
|
44
|
}
|
45
|
// JQ Sky added lines for the 6 x hdr and footer variable @@@@@@@@@@@ ENDS @@@@@@@@@@@@@
|
46
|
|
47
|
public function Header()
|
48
|
{
|
49
|
$this->SetY( 10 );
|
50
|
|
51
|
/**
|
52
|
* yes, even here we can use the multicell tag! this will be a local object
|
53
|
*/
|
54
|
|
55
|
$oMulticell = Multicell::getInstance( $this );
|
56
|
$oMulticell->setStyle( "h1", 'Helvetica', "", 7, "170, 170, 170" );
|
57
|
$oMulticell->multiCell( 160, 5, "<h1>". $this->headerTxt . date('j M Y') ."</h1>" );
|
58
|
$this->SetY( $this->tMargin );
|
59
|
}
|
60
|
|
61
|
|
62
|
/**
|
63
|
* Custom Footer
|
64
|
*
|
65
|
* @see Pdf::Footer()
|
66
|
*/
|
67
|
public function Footer()
|
68
|
{
|
69
|
$this->SetY( -30 );
|
70
|
$oMulticell = Multicell::getInstance( $this );
|
71
|
|
72
|
$oMulticell->setStyle( "span", 'Helvetica', "", 6, "170, 170, 170" );
|
73
|
$oMulticell->multiCell(120,-1,'<span>'. $this->address. '</span>', 0, 'L');
|
74
|
$oMulticell->multiCell( 0, 4, '<span>t: '.$this->telephone.' e: '.$this->email.'</span>', 0, 'R');
|
75
|
$oMulticell->multiCell( 150, 7, '<span>'.$this->registration.'</span>');
|
76
|
$oMulticell->setStyle( "h1", 'Helvetica', "B", 10, "170, 170, 170" );
|
77
|
$oMulticell->multiCell( 100, 7, '<h1>'.$this->website.'</h1>' );
|
78
|
|
79
|
$this->SetFont( $this->getDefaultFontName(), 'I', 7 );
|
80
|
$this->SetTextColor( 170, 170, 170 );
|
81
|
// $this->MultiCell( 0, 4, "Page {$this->PageNo()} / {$this->getAliasNbPages()}", 0, 'C' );
|
82
|
$this->MultiCell( 0, 4, "Page {$this->getPageNumGroupAlias()} / {$this->getPageGroupAlias()}", 0, 'C' );
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* Returns the default Font to be used
|
87
|
*
|
88
|
* @return string
|
89
|
*/
|
90
|
public function getDefaultFontName()
|
91
|
{
|
92
|
return 'helvetica';
|
93
|
}
|
94
|
|
95
|
/**
|
96
|
* Draws the margin lines.
|
97
|
* It's helpful during development
|
98
|
*/
|
99
|
|
100
|
public function drawMarginLines()
|
101
|
{
|
102
|
//draw the top and bottom margins
|
103
|
$ytop = $this->tMargin;
|
104
|
$ybottom = $this->h - 20;
|
105
|
|
106
|
$this->SetLineWidth( 0.1 );
|
107
|
$this->SetDrawColor( 150, 150, 150 );
|
108
|
$this->Line( 0, $ytop, $this->w, $ytop );
|
109
|
$this->Line( 0, $ybottom, $this->w, $ybottom );
|
110
|
$this->Line( $this->rMargin, 0, $this->rMargin, $this->h );
|
111
|
$this->Line( $this->w - $this->rMargin, 0, $this->w - $this->rMargin, $this->h );
|
112
|
}
|
113
|
|
114
|
|
115
|
/**
|
116
|
* Disable the Producer and CreationDate. It breaks the functional unit-testing(date always changes)
|
117
|
*/
|
118
|
public function _putinfo()
|
119
|
{
|
120
|
if ( isset( $_SERVER[ 'ENVIRONMENT' ] ) && 'test' == $_SERVER[ 'ENVIRONMENT' ] ) {
|
121
|
|
122
|
$this->file_id = '1234567890';
|
123
|
$this->tcpdf_version = "1.0.0";
|
124
|
|
125
|
if ( !empty( $this->title ) ) {
|
126
|
$this->_out( '/Title ' . $this->_textstring( $this->title ) );
|
127
|
}
|
128
|
if ( !empty( $this->subject ) ) {
|
129
|
$this->_out( '/Subject ' . $this->_textstring( $this->subject ) );
|
130
|
}
|
131
|
if ( !empty( $this->author ) ) {
|
132
|
$this->_out( '/Author ' . $this->_textstring( $this->author ) );
|
133
|
}
|
134
|
if ( !empty( $this->keywords ) ) {
|
135
|
$this->_out( '/Keywords ' . $this->_textstring( $this->keywords ) );
|
136
|
}
|
137
|
if ( !empty( $this->creator ) ) {
|
138
|
$this->_out( '/Creator ' . $this->_textstring( $this->creator ) );
|
139
|
}
|
140
|
return parent::_putinfo();
|
141
|
} else {
|
142
|
return parent::_putinfo();
|
143
|
}
|
144
|
}
|
145
|
|
146
|
/**
|
147
|
* @param string $headerSource
|
148
|
* @return $this
|
149
|
*/
|
150
|
public function setHeaderSource( $headerSource )
|
151
|
{
|
152
|
$this->headerSource = $headerSource;
|
153
|
return $this;
|
154
|
}
|
155
|
|
156
|
}
|
157
|
|