forked from emaijala/MLInvoice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf.php
More file actions
101 lines (91 loc) · 3.41 KB
/
pdf.php
File metadata and controls
101 lines (91 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/*******************************************************************************
MLInvoice: web-based invoicing application.
Copyright (C) 2010-2016 Ere Maijala
This program is free software. See attached LICENSE.
*******************************************************************************/
/*******************************************************************************
MLInvoice: web-pohjainen laskutusohjelma.
Copyright (C) 2010-2016 Ere Maijala
Tämä ohjelma on vapaa. Lue oheinen LICENSE.
*******************************************************************************/
require_once 'tcpdf/tcpdf.php';
class PDF extends TCPDF
{
public $headerLeft = '', $headerCenter = '', $headerRight = '';
public $footerLeft = '', $footerCenter = '', $footerRight = '';
public $printHeaderOnFirstPage = false;
public $printFooterOnFirstPage = false;
public $headerLeftPos = 4;
public $headerRightPos = 143;
public $footerLeftPos = 4;
public $footerRightPos = 143;
public function Header()
{
if ($this->PageNo() == 1 && !$this->printHeaderOnFirstPage)
return;
$this->SetY(10);
$this->SetFont('Helvetica', '', 7);
$this->SetX($this->headerLeftPos);
$this->MultiCell(120, 5, $this->handlePageNum($this->headerLeft), 0, 'L', 0,
0);
$this->SetX(75);
$this->MultiCell(65, 5, $this->handlePageNum($this->headerCenter), 0, 'C', 0,
0);
$this->SetX($this->headerRightPos);
$this->MultiCell(60, 5, $this->handlePageNum($this->headerRight), 0, 'R', 0,
0);
}
public function Footer()
{
if ($this->PageNo() == 1 && !$this->printFooterOnFirstPage)
return;
$this->SetY(-17);
$this->SetFont('Helvetica', '', 7);
$this->SetX($this->footerLeftPos);
$this->MultiCell(120, 5, $this->footerLeft, 0, 'L', 0, 0);
$this->SetX(75);
$this->MultiCell(65, 5, $this->footerCenter, 0, 'C', 0, 0);
$this->SetX($this->footerRightPos);
$this->MultiCell(60, 5, $this->footerRight, 0, 'R', 0, 0);
}
protected function handlePageNum($str)
{
return sprintf($str, $this->PageNo());
}
// Disable openssl_random_pseudo_bytes call as it's very slow on Windows
protected function getRandomSeed($seed = '')
{
$seed .= microtime();
// if (function_exists('openssl_random_pseudo_bytes')) {
// $seed .= openssl_random_pseudo_bytes(512);
// }
$seed .= uniqid('', true);
$seed .= rand();
$seed .= getmypid();
$seed .= __FILE__;
$seed .= $this->bufferlen;
if (isset($_SERVER['REMOTE_ADDR'])) {
$seed .= $_SERVER['REMOTE_ADDR'];
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$seed .= $_SERVER['HTTP_USER_AGENT'];
}
if (isset($_SERVER['HTTP_ACCEPT'])) {
$seed .= $_SERVER['HTTP_ACCEPT'];
}
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
$seed .= $_SERVER['HTTP_ACCEPT_ENCODING'];
}
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$seed .= $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
$seed .= $_SERVER['HTTP_ACCEPT_CHARSET'];
}
$seed .= rand();
$seed .= uniqid('', true);
$seed .= microtime();
return $seed;
}
}