Initial Commit of AgileBill Open Source

This commit is contained in:
unknown
2008-11-26 14:50:40 -08:00
parent ae5a0fc25e
commit 02306ccc47
2954 changed files with 410976 additions and 0 deletions

202
includes/pdf/LICENSE Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,97 @@
<?php
//
// FPDI - Version 1.1
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
if (!defined("ORD_z"))
define("ORD_z",ord('z'));
if (!defined("ORD_!"))
define("ORD_exclmark", ord('!'));
if (!defined("ORD_u"))
define("ORD_u", ord("u"));
if (!defined("ORD_tilde"))
define("ORD_tilde", ord('~'));
class ASCII85Decode {
function ASCII85Decode(&$fpdi) {
$this->fpdi =& $fpdi;
}
function decode($in) {
$out = "";
$state = 0;
$chn = null;
$l = strlen($in);
for ($k = 0; $k < $l; ++$k) {
$ch = ord($in[$k]) & 0xff;
if ($ch == ORD_tilde) {
break;
}
if (preg_match("/^\s$/",chr($ch))) {
continue;
}
if ($ch == ORD_z && $state == 0) {
$out .= chr(0).chr(0).chr(0).chr(0);
continue;
}
if ($ch < ORD_exclmark || $ch > ORD_u) {
$this->fpdi->error("Illegal character in ASCII85Decode.");
}
$chn[$state++] = $ch - ORD_exclmark;
if ($state == 5) {
$state = 0;
$r = 0;
for ($j = 0; $j < 5; ++$j)
$r = $r * 85 + $chn[$j];
$out .= chr($r >> 24);
$out .= chr($r >> 16);
$out .= chr($r >> 8);
$out .= chr($r);
}
}
$r = 0;
if ($state == 1)
$this->fpdi->error("Illegal length in ASCII85Decode.");
if ($state == 2) {
$r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1]+1) * 85 * 85 * 85;
$out .= chr($r >> 24);
}
else if ($state == 3) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + ($chn[2]+1) * 85 * 85;
$out .= chr($r >> 24);
$out .= chr($r >> 16);
}
else if ($state == 4) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + $chn[2] * 85 * 85 + ($chn[3]+1) * 85 ;
$out .= chr($r >> 24);
$out .= chr($r >> 16);
$out .= chr($r >> 8);
}
return $out;
}
}
?>

View File

@@ -0,0 +1,151 @@
<?php
//
// FPDI - Version 1.1
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class LZWDecode {
var $sTable = array();
var $data = null;
var $tIdx;
var $bitsToGet = 9;
var $bytePointer;
var $bitPointer;
var $nextData = 0;
var $nextBits = 0;
var $andTable = array(511, 1023, 2047, 4095);
function LZWDecode(&$fpdi) {
$this->fpdi =& $fpdi;
}
/**
* Method to decode LZW compressed data.
*
* @param string data The compressed data.
*/
function decode(&$data) {
if($data[0] == 0x00 && $data[1] == 0x01) {
$this->fpdi->error("LZW flavour not supported.");
}
$this->initsTable();
$this->data =& $data;
// Initialize pointers
$this->bytePointer = 0;
$this->bitPointer = 0;
$this->nextData = 0;
$this->nextBits = 0;
$oldCode = 0;
$string = "";
$uncompData = "";
while (($code = $this->getNextCode()) != 257) {
if ($code == 256) {
$this->initsTable();
$code = $this->getNextCode();
if ($code == 257) {
break;
}
$uncompData .= $this->sTable[$code];
$oldCode = $code;
} else {
if ($code < $this->tIdx) {
$string = $this->sTable[$code];
$uncompData .= $string;
$this->addStringToTable($this->sTable[$oldCode], $string[0]);
$oldCode = $code;
} else {
$string = $this->sTable[$oldCode];
$string = $string.$string[0];
$uncompData .= $string;
$this->addStringToTable($string);
$oldCode = $code;
}
}
}
return $uncompData;
}
/**
* Initialize the string table.
*/
function initsTable() {
$this->sTable = array();
for ($i = 0; $i < 256; $i++)
$this->sTable[$i] = chr($i);
$this->tIdx = 258;
$this->bitsToGet = 9;
}
/**
* Add a new string to the string table.
*/
function addStringToTable ($oldString, $newString="") {
$string = $oldString.$newString;
// Add this new String to the table
$this->sTable[$this->tIdx++] = $string;
if ($this->tIdx == 511) {
$this->bitsToGet = 10;
} else if ($this->tIdx == 1023) {
$this->bitsToGet = 11;
} else if ($this->tIdx == 2047) {
$this->bitsToGet = 12;
}
}
// Returns the next 9, 10, 11 or 12 bits
function getNextCode() {
if ($this->bytePointer == strlen($this->data))
return 257;
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
$this->nextBits += 8;
if ($this->nextBits < $this->bitsToGet) {
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
$this->nextBits += 8;
}
$code = ($this->nextData >> ($this->nextBits - $this->bitsToGet)) & $this->andTable[$this->bitsToGet-9];
$this->nextBits -= $this->bitsToGet;
return $code;
}
}
?>

View File

@@ -0,0 +1,7 @@
<?php
for($i=0;$i<=255;$i++)
$fpdf_charwidths['courier'][chr($i)]=600;
$fpdf_charwidths['courierB']=$fpdf_charwidths['courier'];
$fpdf_charwidths['courierI']=$fpdf_charwidths['courier'];
$fpdf_charwidths['courierBI']=$fpdf_charwidths['courier'];
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helvetica']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helveticaB']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helveticaBI']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helveticaI']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['symbol']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,
','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,
'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,
'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,
'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,
chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,
chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,
chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,
chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,
chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['times']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,
'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,
'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,
chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['timesB']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,
'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,
'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,
chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['timesBI']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,
'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,
'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,
chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['timesI']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,
'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,
'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,
'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,
chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,
chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,
chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['zapfdingbats']=array(
chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
?>

1648
includes/pdf/fpdf.php Normal file

File diff suppressed because it is too large Load Diff

446
includes/pdf/fpdf_tpl.php Normal file
View File

@@ -0,0 +1,446 @@
<?php
//
// fpdf_tpl - Version 1.0.2
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
require_once("fpdf.php");
class fpdf_tpl extends fpdf {
/**
* Array of Tpl-Data
* @var array
*/
var $tpls = array();
/**
* Current Template-ID
* @var int
*/
var $tpl = 0;
/**
* "In Template"-Flag
* @var boolean
*/
var $intpl = false;
/**
* Nameprefix of Templates used in Resources-Dictonary
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
*/
var $tplprefix = "/TPL";
/**
* Nameprefix of Fonts used in Resources-Dictonary
* (not realy needed, but for future versions with import-function needed)
* @var string
*/
var $fontprefix = "/F";
/**
* Resources used By Templates and Pages
* @var array
*/
var $res = array();
/**
* Constructor
* See FPDF-Documentation
* @param string $orientation
* @param string $unit
* @param mixed $format
*/
function fpdf_tpl($orientation='P',$unit='mm',$format='A4') {
parent::fpdf($orientation,$unit,$format);
}
/**
* Start a Template
*
* This method starts a template. You can give own coordinates to build an own sized
* Template. Pay attention, that the margins are adapted to the new templatesize.
* If you want to write outside the template, for example to build a clipped Template,
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
*
* If no parameter is given, the template uses the current page-size.
* The Method returns an ID of the current Template. This ID is used later for using this template.
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The ID of new created Template
*/
function beginTemplate($x=null,$y=null,$w=null,$h=null) {
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
// Save settings
$this->tpl++;
$this->tpls[$this->tpl]['o_x'] = $this->x;
$this->tpls[$this->tpl]['o_y'] = $this->y;
$this->tpls[$this->tpl]['o_AutoPageBreak'] = $this->AutoPageBreak;
$this->tpls[$this->tpl]['o_bMargin'] = $this->bMargin;
$this->tpls[$this->tpl]['o_tMargin'] = $this->tMargin;
$this->tpls[$this->tpl]['o_lMargin'] = $this->lMargin;
$this->tpls[$this->tpl]['o_rMargin'] = $this->rMargin;
$this->tpls[$this->tpl]['o_h'] = $this->h;
$this->tpls[$this->tpl]['o_w'] = $this->w;
$this->SetAutoPageBreak(false);
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Define own high and width to calculate possitions correct
$this->h = $h;
$this->w = $w;
$this->tpls[$this->tpl]['buffer'] = "";
$this->tpls[$this->tpl]['x'] = $x;
$this->tpls[$this->tpl]['y'] = $y;
$this->tpls[$this->tpl]['w'] = $w;
$this->tpls[$this->tpl]['h'] = $h;
$this->intpl = true;
$this->SetXY($x+$this->lMargin,$y+$this->tMargin);
$this->SetRightMargin($this->w-$w+$this->rMargin);
return $this->tpl;
}
/**
* End Template
*
* This method ends a template and reset initiated variables on beginTemplate.
*
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/
function endTemplate() {
if ($this->intpl) {
$this->intpl = false;
$this->SetAutoPageBreak($this->tpls[$this->tpl]['o_AutoPageBreak'],$this->tpls[$this->tpl]['o_bMargin']);
$this->SetXY($this->tpls[$this->tpl]['o_x'],$this->tpls[$this->tpl]['o_y']);
$this->tMargin = $this->tpls[$this->tpl]['o_tMargin'];
$this->lMargin = $this->tpls[$this->tpl]['o_lMargin'];
$this->rMargin = $this->tpls[$this->tpl]['o_rMargin'];
$this->h = $this->tpls[$this->tpl]['o_h'];
$this->w = $this->tpls[$this->tpl]['o_w'];
return $this->tpl;
} else {
return false;
}
}
/**
* Use a Template in current Page or other Template
*
* You can use a template in a page or in another template.
* You can give the used template a new size like you use the Image()-method.
* All parameters are optional. The width or height is calculated automaticaly
* if one is given. If no parameter is given the origin size as defined in
* beginTemplate() is used.
* The calculated or used width and height are returned as an array.
*
* @param int $tplidx A valid template-Id
* @param int $_x The x-position
* @param int $_y The y-position
* @param int $_w The new width of the template
* @param int $_h The new height of the template
* @retrun array The height and width of the template
*/
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if (!$this->tpls[$tplidx])
$this->error("Template does not exist!");
if ($this->intpl) {
$this->res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
}
extract($this->tpls[$tplidx]);
if ($_x == null)
$_x = $x;
if ($_y == null)
$_y = $y;
$wh = $this->getTemplateSize($tplidx,$_w,$_h);
$_w = $wh['w'];
$_h = $wh['h'];
$this->_out(sprintf("q %.4f 0 0 %.4f %.2f %.2f cm", ($_w/$w), ($_h/$h), $_x*$this->k, ($this->h-($_y+$_h))*$this->k)); // Translate
$this->_out($this->tplprefix.$tplidx." Do Q");
return array("w" => $_w, "h" => $_h);
}
/**
* Get The calculated Size of a Template
*
* If one size is given, this method calculates the other one.
*
* @param int $tplidx A valid template-Id
* @param int $_w The width of the template
* @param int $_h The height of the template
* @return array The height and width of the template
*/
function getTemplateSize($tplidx, $_w=0, $_h=0) {
if (!$this->tpls[$tplidx])
return false;
extract($this->tpls[$tplidx]);
if ($_w == 0 and $_h == 0) {
$_w = $w;
$_h = $h;
}
if($_w==0)
$_w=$_h*$w/$h;
if($_h==0)
$_h=$_w*$h/$w;
return array("w" => $_w, "h" => $_h);
}
/**
* See FPDF-Documentation ;-)
*/
function SetFont($family,$style='',$size=0) {
//Select a font; size given in points
global $fpdf_charwidths;
$family=strtolower($family);
if($family=='')
$family=$this->FontFamily;
if($family=='arial')
$family='helvetica';
elseif($family=='symbol' or $family=='zapfdingbats')
$style='';
$style=strtoupper($style);
if(is_int(strpos($style,'U')))
{
$this->underline=true;
$style=str_replace('U','',$style);
}
else
$this->underline=false;
if($style=='IB')
$style='BI';
if($size==0)
$size=$this->FontSizePt;
//Test if font is already selected
if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size and !$this->intpl)
return;
//Test if used for the first time
$fontkey=$family.$style;
if(!isset($this->fonts[$fontkey]))
{
//Check if one of the standard fonts
if(isset($this->CoreFonts[$fontkey]))
{
if(!isset($fpdf_charwidths[$fontkey]))
{
//Load metric file
$file=$family;
if($family=='times' or $family=='helvetica')
$file.=strtolower($style);
$file.='.php';
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
include($file);
if(!isset($fpdf_charwidths[$fontkey]))
$this->Error('Could not include font metric file');
}
$i = $this->findNextAvailFont();
$this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]);
}
else
$this->Error('Undefined font: '.$family.' '.$style);
}
//Select it
$this->FontFamily=$family;
$this->FontStyle=$style;
$this->FontSizePt=$size;
$this->FontSize=$size/$this->k;
$this->CurrentFont=&$this->fonts[$fontkey];
if($this->page>0)
$this->_out(sprintf('BT '.$this->fontprefix.'%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
if ($this->intpl) {
$this->res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* Find the next available Font-No.
*
* @return int
*/
function findNextAvailFont() {
return count($this->fonts)+1;
}
/**
* See FPDF-Documentation ;-)
*/
function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') {
parent::Image($file,$x,$y,$w,$h,$type,$link);
if ($this->intpl) {
$this->res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
}
/**
* See FPDF-Documentation ;-)
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation='') {
if ($this->intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation);
}
/**
* Preserve adding Links in Templates ...won't work
*/
function Link($x,$y,$w,$h,$link) {
if ($this->intpl)
$this->Error('Using links in templates aren\'t possible!');
parent::Link($x,$y,$w,$h,$link);
}
function AddLink() {
if ($this->intpl)
$this->Error('Adding links in templates aren\'t possible!');
return parent::AddLink();
}
function SetLink($link,$y=0,$page=-1) {
if ($this->intpl)
$this->Error('Setting links in templates aren\'t possible!');
parent::SetLink($link,$y,$page);
}
/**
* Private Method that writes the Resources-Objects
*/
function _puttemplates() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',$tpl['x']*$this->k, ($tpl['h']-$tpl['y'])*$this->k, $tpl['w']*$this->k, ($tpl['h']-$tpl['y']-$tpl['h'])*$this->k)); // ($this->h-$tpl['y'])*$this->k
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (count($this->res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->res['tpl'][$tplidx]['fonts'] as $font)
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
}
if(count($this->res['tpl'][$tplidx]['images']) || count($this->res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (count($this->res['tpl'][$tplidx]['images'])) {
foreach($this->res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
}
if (count($this->res['tpl'][$tplidx]['tpls'])) {
foreach($this->res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('/Length '.strlen($p).' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Private Method
*/
function _putresources() {
$this->_putfonts();
$this->_putimages();
$this->_puttemplates();
//Resource dictionary
$this->offsets[2]=strlen($this->buffer);
$this->_out('2 0 obj');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
$this->_out('/Font <<');
foreach($this->fonts as $font)
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
if(count($this->images) || count($this->tpls))
{
$this->_out('/XObject <<');
if (count($this->images)) {
foreach($this->images as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
}
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl)
$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('endobj');
}
/**
* Private Method
*/
function _out($s) {
//Add a line to the document
if ($this->state==2) {
if (!$this->intpl)
$this->pages[$this->page].=$s."\n";
else
$this->tpls[$this->tpl]['buffer'] .= $s."\n";
} else {
$this->buffer.=$s."\n";
}
}
}
?>

413
includes/pdf/fpdi.php Normal file
View File

@@ -0,0 +1,413 @@
<?php
//
// FPDI - Version 1.1
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
define ('PDF_TYPE_NULL', 0);
define ('PDF_TYPE_NUMERIC', 1);
define ('PDF_TYPE_TOKEN', 2);
define ('PDF_TYPE_HEX', 3);
define ('PDF_TYPE_STRING', 4);
define ('PDF_TYPE_DICTIONARY', 5);
define ('PDF_TYPE_ARRAY', 6);
define ('PDF_TYPE_OBJDEC', 7);
define ('PDF_TYPE_OBJREF', 8);
define ('PDF_TYPE_OBJECT', 9);
define ('PDF_TYPE_STREAM', 10);
ini_set('auto_detect_line_endings',1); // Strongly required!
require_once("fpdf_tpl.php");
require_once("fpdi_pdf_parser.php");
class fpdi extends fpdf_tpl {
/**
* Actual filename
* @var string
*/
var $current_filename;
/**
* Parser-Objects
* @var array
*/
var $parsers;
/**
* Current parser
* @var object
*/
var $current_parser;
/**
* FPDF/FPDI - PDF-Version
* @var double
*/
var $PDFVersion = 1.3;
/**
* Highest version of imported PDF
* @var double
*/
var $importVersion = 1.3;
/**
* object stack
* @var array
*/
var $obj_stack;
/**
* done object stack
* @var array
*/
var $don_obj_stack;
/**
* Current Object Id.
* @var integer
*/
var $current_obj_id;
/**
* Constructor
* See FPDF-Manual
*/
function fpdi($orientation='P',$unit='mm',$format='A4') {
parent::fpdf_tpl($orientation,$unit,$format);
}
/**
* Set a source-file
*
* @param string $filename a valid filename
* @return int number of available pages
*/
function setSourceFile($filename) {
$this->current_filename = $filename;
$fn =& $this->current_filename;
$this->parsers[$fn] = new fpdi_pdf_parser($fn,$this);
$this->current_parser =& $this->parsers[$fn];
return $this->parsers[$fn]->getPageCount();
}
/**
* Import a page
*
* @param int $pageno pagenumber
* @return int Index of imported page - to use with fpdf_tpl::useTemplate()
*/
function ImportPage($pageno) {
$fn =& $this->current_filename;
$this->parsers[$fn]->setPageno($pageno);
$this->tpl++;
$this->tpls[$this->tpl] = array();
$this->tpls[$this->tpl]['parser'] =& $this->parsers[$fn];
$this->tpls[$this->tpl]['resources'] = $this->parsers[$fn]->getPageResources();
$this->tpls[$this->tpl]['buffer'] = $this->parsers[$fn]->getContent();
// $mediabox holds the dimensions of the source page
$mediabox = $this->parsers[$fn]->getPageMediaBox($pageno);
// To build array that can used by pdf_tpl::useTemplate()
$this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl],$mediabox);
return $this->tpl;
}
/**
* Private method, that rebuilds all needed objects of source files
*/
function _putOobjects() {
if (is_array($this->parsers) && count($this->parsers) > 0) {
foreach($this->parsers AS $filename => $p) {
$this->current_parser =& $this->parsers[$filename];
if (is_array($this->obj_stack[$filename])) {
while($n = key($this->obj_stack[$filename])) {
$nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c,$this->obj_stack[$filename][$n][1]);
$this->_newobj($this->obj_stack[$filename][$n][0]);
if ($nObj[0] == PDF_TYPE_STREAM) {
$this->pdf_write_value ($nObj);
} else {
$this->pdf_write_value ($nObj[1]);
}
$this->_out('endobj');
$this->obj_stack[$filename][$n] = null; // free memory
unset($this->obj_stack[$filename][$n]);
reset($this->obj_stack[$filename]);
}
}
}
}
}
/**
* Rewritten for handling own defined PDF-Versions
* only needed by FPDF 1.52
*/
function _begindoc() {
//Start document
$this->state=1;
}
/**
* Sets the PDF Version to the highest of imported documents
*/
function setVersion() {
if ($this->importVersion > $this->PDFVersion)
$this->PDFVersion = $this->importVersion;
if (!method_exists($this, '_putheader')) {
$this->buffer = '%PDF-'.$this->PDFVersion."\n".$this->buffer;
}
}
/**
* rewritten for handling higher PDF Versions
*/
function _enddoc() {
$this->setVersion();
parent::_enddoc();
}
/**
* Put resources
*/
function _putresources() {
$this->_putfonts();
$this->_putimages();
$this->_puttemplates();
$this->_putOobjects();
//Resource dictionary
$this->offsets[2]=strlen($this->buffer);
$this->_out('2 0 obj');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
$this->_out('/Font <<');
foreach($this->fonts as $font)
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
if(count($this->images) || count($this->tpls))
{
$this->_out('/XObject <<');
if (count($this->images)) {
foreach($this->images as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
}
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl)
$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('endobj');
}
/**
* Private Method that writes /XObjects - "Templates"
*/
function _puttemplates() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',$tpl['x']*$this->k, ($tpl['h']-$tpl['y'])*$this->k, $tpl['w']*$this->k, ($tpl['h']-$tpl['y']-$tpl['h'])*$this->k));
$this->_out('/Resources ');
if ($tpl['resources']) {
$this->current_parser =& $tpl['parser'];
$this->pdf_write_value($tpl['resources']);
} else {
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (count($this->res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->res['tpl'][$tplidx]['fonts'] as $font)
$this->_out($this->fontprefix.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
}
if(count($this->res['tpl'][$tplidx]['images']) || count($this->res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (count($this->res['tpl'][$tplidx]['images'])) {
foreach($this->res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
}
if (count($this->res['tpl'][$tplidx]['tpls'])) {
foreach($this->res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
}
$this->_out('/Length '.strlen($p).' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Rewritten to handle existing own defined objects
*/
function _newobj($obj_id=false,$onlynewobj=false) {
if (!$obj_id) {
$obj_id = ++$this->n;
}
//Begin a new object
if (!$onlynewobj) {
$this->offsets[$obj_id]=strlen($this->buffer);
$this->_out($obj_id.' 0 obj');
$this->current_obj_id = $obj_id; // for later use with encryption
}
}
/**
* Writes a value
* Needed to rebuild the source document
*
* @param mixed $value A PDF-Value. Structure of values see cases in this method
*/
function pdf_write_value(&$value)
{
switch ($value[0]) {
case PDF_TYPE_NUMERIC :
case PDF_TYPE_TOKEN :
// A numeric value or a token.
// Simply output them
$this->_out($value[1]." ");
break;
case PDF_TYPE_ARRAY :
// An array. Output the proper
// structure and move on.
$this->_out("[",false);
for ($i = 0; $i < count($value[1]); $i++) {
$this->pdf_write_value($value[1][$i]);
}
$this->_out("]");
break;
case PDF_TYPE_DICTIONARY :
// A dictionary.
$this->_out("<<",false);
reset ($value[1]);
while (list($k, $v) = each($value[1])) {
$this->_out($k . " ",false);
$this->pdf_write_value($v);
}
$this->_out(">>");
break;
case PDF_TYPE_OBJREF :
// An indirect object reference
// Fill the object stack if needed
if (!isset($this->don_obj_stack[$this->current_parser->filename][$value[1]])) {
$this->_newobj(false,true);
$this->obj_stack[$this->current_parser->filename][$value[1]] = array($this->n,$value);
$this->don_obj_stack[$this->current_parser->filename][$value[1]] = array($this->n,$value);
}
$objid = $this->don_obj_stack[$this->current_parser->filename][$value[1]][0];
$this->_out("{$objid} 0 R"); //{$value[2]}
break;
case PDF_TYPE_STRING :
// A string.
$this->_out('(' . $value[1] . ')');
break;
case PDF_TYPE_STREAM :
// A stream. First, output the
// stream dictionary, then the
// stream data itself.
$this->pdf_write_value($value[1]);
$this->_out("stream");
$this->_out($value[2][1]);
$this->_out("endstream");
break;
case PDF_TYPE_HEX :
$this->_out("<" . $value[1] . ">");
break;
case PDF_TYPE_NULL :
// The null object.
$this->_out("null");
break;
}
}
/**
* Private Method
*/
function _out($s,$ln=true) {
//Add a line to the document
if ($this->state==2) {
if (!$this->intpl)
$this->pages[$this->page].=$s.($ln == true ? "\n" : '');
else
$this->tpls[$this->tpl]['buffer'] .= $s.($ln == true ? "\n" : '');
} else {
$this->buffer.=$s.($ln == true ? "\n" : '');
}
}
/**
* close all files opened by parsers
*/
function closeParsers() {
foreach ($this->parsers as $parser){
$parser->closeFile();
}
}
}
?>

View File

@@ -0,0 +1,482 @@
<?php
//
// FPDI - Version 1.1
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
if (!defined ('PDF_TYPE_NULL'))
define ('PDF_TYPE_NULL', 0);
if (!defined ('PDF_TYPE_NUMERIC'))
define ('PDF_TYPE_NUMERIC', 1);
if (!defined ('PDF_TYPE_TOKEN'))
define ('PDF_TYPE_TOKEN', 2);
if (!defined ('PDF_TYPE_HEX'))
define ('PDF_TYPE_HEX', 3);
if (!defined ('PDF_TYPE_STRING'))
define ('PDF_TYPE_STRING', 4);
if (!defined ('PDF_TYPE_DICTIONARY'))
define ('PDF_TYPE_DICTIONARY', 5);
if (!defined ('PDF_TYPE_ARRAY'))
define ('PDF_TYPE_ARRAY', 6);
if (!defined ('PDF_TYPE_OBJDEC'))
define ('PDF_TYPE_OBJDEC', 7);
if (!defined ('PDF_TYPE_OBJREF'))
define ('PDF_TYPE_OBJREF', 8);
if (!defined ('PDF_TYPE_OBJECT'))
define ('PDF_TYPE_OBJECT', 9);
if (!defined ('PDF_TYPE_STREAM'))
define ('PDF_TYPE_STREAM', 10);
require_once("wrapper_functions.php");
require_once("pdf_parser.php");
class fpdi_pdf_parser extends pdf_parser {
/**
* Pages
* Index beginns at 0
*
* @var array
*/
var $pages;
/**
* Page count
* @var integer
*/
var $page_count;
/**
* actual page number
* @var integer
*/
var $pageno;
/**
* PDF Version of imported Document
* @var string
*/
var $pdfVersion;
/**
* FPDI Reference
* @var object
*/
var $fpdi;
/**
* Constructor
*
* @param string $filename Source-Filename
* @param object $fpdi Object of type fpdi
*/
function fpdi_pdf_parser($filename,&$fpdi) {
$this->fpdi =& $fpdi;
$this->filename = $filename;
parent::pdf_parser($filename);
// Get Info
$this->getInfo();
// resolve Pages-Dictonary
$pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']);
// Read pages
$this->read_pages($this->c, $pages, $this->pages);
// count pages;
$this->page_count = count($this->pages);
}
/**
* Overwrite parent::error()
*
* @param string $msg Error-Message
*/
function error($msg) {
$this->fpdi->error($msg);
}
/**
* Get pagecount from sourcefile
*
* @return int
*/
function getPageCount() {
return $this->page_count;
}
/**
* Set pageno
*
* @param int $pageno Pagenumber to use
*/
function setPageno($pageno) {
$pageno-=1;
if ($pageno < 0 || $pageno >= $this->getPageCount()) {
$this->fpdi->error("Pagenumber is wrong!");
}
$this->pageno = $pageno;
}
/**
* Get page-resources from current page
*
* @return array
*/
function getPageResources() {
return $this->_getPageResources($this->pages[$this->pageno]);
}
/**
* Get page-resources from /Page
*
* @param array $obj Array of pdf-data
*/
function _getPageResources ($obj) { // $obj = /Page
$obj = $this->pdf_resolve_object($this->c, $obj);
// If the current object has a resources
// dictionary associated with it, we use
// it. Otherwise, we move back to its
// parent object.
if (isset ($obj[1][1]['/Resources'])) {
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
} else {
if (!isset ($obj[1][1]['/Parent'])) {
return false;
} else {
$res = $this->_getPageResources($obj[1][1]['/Parent']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
}
}
}
function getInfo() {
$avail_infos = array("Title", "Author", "Subject", "Keywords", "Creator", "Producer", "CreationDate", "ModDate", "Trapped");
$_infos = $this->pdf_resolve_object($this->c,$this->xref['trailer'][1]['/Info']);
$infos = array();
foreach ($avail_infos AS $info) {
if (isset($_infos[1][1]["/".$info])) {
if ($_infos[1][1]["/".$info][0] == PDF_TYPE_STRING) {
$infos[$info] = $this->deescapeString($_infos[1][1]["/".$info][1]);
} else if ($_infos[1][1]["/".$info][0] == PDF_TYPE_HEX) {
$infos[$info] = $this->hex2String($_infos[1][1]["/".$info][1]);
}
}
}
$this->infos = $infos;
}
/**
* Rebuilds a hexstring to string
*
* @param string $hex hexstring
* @return string
*/
function hex2String($hex) {
$endian = false;
if (preg_match("/^FEFF/",$hex)) { // is utf-16 aka big endian
$i = 4;
$endian = "big";
} else if (preg_match("/^FFFE/",$hex)) { // is utf-16 aka little endian
$i = 4;
$endian = "little";
} else {
$i = 0;
}
$s = "";
$l = strlen($hex);
for (; $i < $l; $i+=2) {
if (!$endian) {
$s .= chr(hexdec($hex[$i].(isset($hex[$i+1]) ? $hex[$i+1] : '0')));
} else {
if ($endian == "big") {
$_c = $hex[$i].$hex[$i+1];
$i+=2;
$c = $hex[$i].$hex[$i+1];
if ($_c != "00") {
$s .= "?";
continue;
} else {
$s .= chr(hexdec($c));
continue;
}
} else if ($endian == "little") {
$c = $hex[$i].$hex[$i+1];
$i+=2;
$_c = $hex[$i].$hex[$i+1];
if ($_c != "00") {
$s .= "?";
continue;
} else {
$s .= chr(hexdec($c));
continue;
}
}
}
}
return $s;
}
function deescapeString($s) {
$torepl = array("/\\\(\d{1,3})/e" => "chr(octdec(\\1))",
"/\\\\\(/" => "(",
"/\\\\\)/" => ")");
return preg_replace(array_keys($torepl),$torepl,$s);
}
/**
* Get content of current page
*
* If more /Contents is an array, the streams are concated
*
* @return string
*/
function getContent() {
$buffer = "";
$contents = $this->getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
foreach($contents AS $tmp_content) {
$buffer .= $this->rebuildContentStream($tmp_content);
}
return $buffer;
}
/**
* Resolve all content-objects
*
* @param array $content_ref
* @return array
*/
function getPageContent($content_ref) {
$contents = array();
if ($content_ref[0] == PDF_TYPE_OBJREF) {
$content = $this->pdf_resolve_object($this->c, $content_ref);
if ($content[1][0] == PDF_TYPE_ARRAY) {
$contents = $this->getPageContent($content[1]);
} else {
$contents[] = $content;
}
} else if ($content_ref[0] == PDF_TYPE_ARRAY) {
foreach ($content_ref[1] AS $tmp_content_ref) {
$contents = array_merge($contents,$this->getPageContent($tmp_content_ref));
}
}
return $contents;
}
/**
* Rebuild content-streams
* only non-compressed streams and /FlateDecode are ready!
*
* @param array $obj
* @return string
*/
function rebuildContentStream($obj) {
$filters = array();
if (isset($obj[1][1]['/Filter'])) {
$_filter = $obj[1][1]['/Filter'];
if ($_filter[0] == PDF_TYPE_TOKEN) {
$filters[] = $_filter;
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
$filters = $_filter[1];
}
}
$stream = $obj[2][1];
foreach ($filters AS $_filter) {
switch ($_filter[1]) {
case "/FlateDecode":
if (function_exists('gzuncompress')) {
$stream = @gzuncompress($stream);
} else {
$this->fpdi->error(sprintf("To handle %s filter, please compile php with zlib support.",$_filter[1]));
}
if ($stream === false) {
$this->fpdi->error("Error while decompressing string.");
}
break;
case "/LZWDecode":
@include_once("decoders/lzw.php");
if (class_exists("LZWDecode")) {
$lzwdec = new LZWDecode($this->fpdi);
$stream = $lzwdec->decode($stream);
} else {
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
}
break;
case "/ASCII85Decode":
@include_once("decoders/ascii85.php");
if (class_exists("ASCII85Decode")) {
$ascii85 = new ASCII85Decode($this->fpdi);
$stream = $ascii85->decode(trim($stream));
} else {
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
}
break;
case null:
$stream = $stream;
break;
default:
$this->fpdi->error(sprintf("Unsupported Filter: %s",$_filter[1]));
}
}
return $stream;
}
/**
* Get MediaBox
*
* gets an array that describes the size of a page.
*
* @param integer $pageno
* @return array @see getPageBox()
*/
function getPageMediaBox($pageno) {
return $this->getPageBox($this->pages[$pageno-1],"/MediaBox");
}
/**
* Get a Box from a page
* Arrayformat is same as used by fpdf_tpl
*
* @param array $page a /Page
* @param string $box_index Type of Box @see getPageBoxes()
* @return array
*/
function getPageBox($page, $box_index) {
$page = $this->pdf_resolve_object($this->c,$page);
$box = null;
if (isset($page[1][1][$box_index]))
$box =& $page[1][1][$box_index];
if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
$tmp_box = $this->pdf_resolve_object($this->c,$box);
$box = $tmp_box[1];
}
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
$b =& $box[1];
return array("x" => $b[0][1]/$this->fpdi->k,
"y" => $b[1][1]/$this->fpdi->k,
"w" => $b[2][1]/$this->fpdi->k,
"h" => $b[3][1]/$this->fpdi->k);
} else if (!isset ($page[1][1]['/Parent'])) {
return false;
} else {
return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index);
}
}
/**
* Get all Boxes from /Page
*
* @param array a /Page
* @return array
*/
function getPageBoxes($page) {
$_boxes = array("/MediaBox","/CropBox","/BleedBox","/TrimBox","/ArtBox");
$boxes = array();
foreach($_boxes AS $box) {
if ($_box = $this->getPageBox($page,$box)) {
$boxes[$box] = $_box;
}
}
return $boxes;
}
/**
* Read all /Page(es)
*
* @param object pdf_context
* @param array /Pages
* @param array the result-array
*/
function read_pages (&$c, &$pages, &$result) {
// Get the kids dictionary
$kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
if (!is_array($kids))
$this->fpdi->Error("Cannot find /Kids in current /Page-Dictionary");
foreach ($kids[1] as $v) {
$pg = $this->pdf_resolve_object ($c, $v);
#print_r($pg);
if ($pg[1][1]['/Type'][1] === '/Pages') {
// If one of the kids is an embedded
// /Pages array, resolve it as well.
$this->read_pages ($c, $pg, $result);
} else {
$result[] = $pg;
}
}
}
/**
* Get PDF-Version
*
* And reset the PDF Version used in FPDI if needed
*/
function getPDFVersion() {
parent::getPDFVersion();
if (isset($this->fpdi->importVersion) && $this->pdfVersion > $this->fpdi->importVersion) {
$this->fpdi->importVersion = $this->pdfVersion;
}
}
}
?>

BIN
includes/pdf/invoice.pdf Normal file

Binary file not shown.

BIN
includes/pdf/invoice1.pdf Normal file

Binary file not shown.

BIN
includes/pdf/invoice2.pdf Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,254 @@
<?php
/*
AgileBill - Base class for all PDF invoice generation
(C) 2006 Agileco LLC. All rights reserved.
File orginally written by Joseph Benden on 1/9/2006
$Id:$
*/
class pdf_invoice_base extends fpdi
{
var $iteration;
var $show_service_range=false;
function load_setup(&$rs)
{
if(!$rs) {
$db =& DB();
$rs = $db->Execute(sqlSelect($db,"setup_invoice","*",""));
}
$this->billToCompany = $rs->fields['bill_to_company'];
$this->invoiceCurrency = $rs->fields['invoice_currency'];
$this->invoiceDecimals = $rs->fields['invoice_decimals'];
$this->itemsSummaryMax = $rs->fields['items_summary_max'];
$this->news = $rs->fields['news'];
$this->pageType = $rs->fields['page_type'];
$this->show_itemized = $rs->fields['invoice_show_itemized'];
$this->show_service_range = $rs->fields['invoice_show_service_dates'];
$this->contact_us_url = $rs->fields['contact_us_url'];
$this->contact_us_phone = $rs->fields['contact_us_phone'];
#$this->currency;
$this->currency = $rs->fields['invoice_currency'];
}
function drawCustom() {
}
function getTemplate() {
return PATH_INCLUDES."pdf/invoice.pdf";
}
function drawCompanyLogo() {
}
function drawCompanyAddress() {
}
function drawAccountMailing() {
}
function drawAccountId() {
}
function drawAccountName() {
}
function drawAccountUsername() {
}
function drawAccountAddress() {
}
function drawInvoiceNo() {
}
function drawInvoiceCreatedDate() {
}
function drawInvoiceRange() {
}
function drawInvoiceDueDate() {
}
function drawInvoiceTotalAmt() {
}
function drawInvoicePaidAmt() {
}
function drawInvoiceDueAmt() {
}
function drawInvoiceDiscountAmt() {
}
function drawInvoiceDueNotice() {
}
function drawInvoicePaidNotice() {
}
function drawInvoiceTaxAmt() {
}
function drawInvoiceShippingAmt() {
}
/**
* Actual second plus pages of details. This is the constructor.
*/
function drawLineItems_pre($iteration) {
}
/**
* This is called for each line item on the second plus pages of details.
*/
function drawLineItems(&$db, &$line) {
}
/**
* Draws the summary on the first page
*/
function drawSummaryLineItems($items) {
}
/**
* Assigns the invoice fields to this object.
*/
function setInvoiceFields($flds) {
$this->invoice = $flds;
}
/**
* Assigns the account fields to this object.
*/
function setAccountFields($flds) {
$this->account = $flds;
}
/**
* Assigns the item summary fields to this object.
*/
function setItemsSummary($items) {
$this->itemsSummary = $items;
}
function setItemsFull($items) {
$this->itemsFull = $items;
}
function setDateRange($periodStart, $periodEnd) {
$this->dateRange = date(UNIX_DATE_FORMAT, $periodStart) . ' - ' . date(UNIX_DATE_FORMAT, $periodEnd);
}
function setCurrency($currency) {
$this->invoiceCurrency = $currency;
}
function setDecimals($decimals) {
$this->invoiceDecimals = $decimals;
}
function setLateFeeNotice() {
}
function setDueAmt($amt) {
$this->invoiceDueAmt=$amt;
}
function setNetTerms($terms) {
$this->netTerms=$terms;
}
function _currency($num) {
global $C_list;
if($this->invoiceDecimals>3)
return $this->invoiceCurrency . number_format($num, $this->invoiceDecimals);
else
return $C_list->format_currency_num($num, $this->invoice['actual_billed_currency_id']);
}
function _putpages() {
$nb=$this->page;
if(!empty($this->AliasNbPages))
{
//Replace number of pages
for($n=1;$n<=$nb;$n++)
$this->pages[$n]=($this->compress) ? gzcompress(str_replace($this->AliasNbPages,$nb,gzuncompress($this->pages[$n]))) : str_replace($this->AliasNbPages,$nb,$this->pages[$n]) ;
}
if($this->DefOrientation=='P')
{
$wPt=$this->fwPt;
$hPt=$this->fhPt;
}
else
{
$wPt=$this->fhPt;
$hPt=$this->fwPt;
}
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
for($n=1;$n<=$nb;$n++)
{
//Page
$this->_newobj();
$this->_out('<</Type /Page');
$this->_out('/Parent 1 0 R');
if(isset($this->OrientationChanges[$n]))
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt));
$this->_out('/Resources 2 0 R');
if(isset($this->PageLinks[$n]))
{
//Links
$annots='/Annots [';
foreach($this->PageLinks[$n] as $pl)
{
$rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
if(is_string($pl[4]))
$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
else
{
$l=$this->links[$pl[4]];
$h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt;
$annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k);
}
}
$this->_out($annots.']');
}
$this->_out('/Contents '.($this->n+1).' 0 R>>');
$this->_out('endobj');
//Page content
$this->_newobj();
$this->_out('<<'.$filter.'/Length '.strlen($this->pages[$n]).'>>');
$this->_putstream($this->pages[$n]);
$this->_out('endobj');
}
//Pages root
$this->offsets[1]=strlen($this->buffer);
$this->_out('1 0 obj');
$this->_out('<</Type /Pages');
$kids='/Kids [';
for($i=0;$i<$nb;$i++)
$kids.=(3+2*$i).' 0 R ';
$this->_out($kids.']');
$this->_out('/Count '.$nb);
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt));
$this->_out('>>');
$this->_out('endobj');
}
function _endpage() {
//End of page contents
$this->pages[$this->page] = ($this->compress) ? gzcompress($this->pages[$this->page]) : $this->pages[$this->page];
$this->state=1;
}
}
?>

View File

@@ -0,0 +1,78 @@
<?php
//
// FPDI - Version 1.1
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class pdf_context {
var $file;
var $buffer;
var $offset;
var $length;
var $stack;
// Constructor
function pdf_context($f) {
$this->file = $f;
$this->reset();
}
// Optionally move the file
// pointer to a new location
// and reset the buffered data
function reset($pos = null, $l = 100) {
if (!is_null ($pos)) {
fseek ($this->file, $pos);
}
$this->buffer = fread($this->file, $l);
$this->offset = 0;
$this->length = strlen($this->buffer);
$this->stack = array();
}
// Make sure that there is at least one
// character beyond the current offset in
// the buffer to prevent the tokenizer
// from attempting to access data that does
// not exist
function ensure_content() {
if ($this->offset >= $this->length - 1) {
return $this->increase_length();
} else {
return true;
}
}
// Forcefully read more data into the buffer
function increase_length($l=100) {
if (feof($this->file)) {
return false;
} else {
$this->buffer .= fread($this->file, $l);
$this->length = strlen($this->buffer);
return true;
}
}
}
?>

View File

@@ -0,0 +1,278 @@
<?php
/*
AgileBill - Default PDF invoice with summary detail
(C) 2006 Agileco LLC. All rights reserved.
$Id:$
*/
require_once PATH_INCLUDES.'pdf/invoice_base.inc.php';
class pdf_invoice_overview extends pdf_invoice_base
{
var $billToCompany = true;
var $invoiceDueAmt = 0;
var $invoiceCurrency = '$';
var $invoiceDecimals = '2';
var $itemsSummary;
var $itemsSummaryMax=6;
var $itemsFull;
var $news = '';
var $v, $i, $y;
var $pageType = 1;
var $show_itemized = 1;
// draw the logo
function drawCompanyLogo() {
$x = 10;
$y = 10;
$width = 50;
if(is_file(PATH_THEMES.'default/images/invoice_logo.jpg'))
$this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',$x,$y,$width);
}
// draw the company address
function drawCompanyAddress() {
// add the company address on the payment stub (1)
$this->SetFont('times','B', 10);
$this->SetXY(18,202); $this->Cell(50,10, $this->companyName);
$this->SetXY(18,206); $this->Cell(50,10, $this->companyAddress);
$this->SetXY(18,210); $this->Cell(50,10, $this->companyCity. ", ". $this->companyState . " " . $this->companyZip);
}
function drawAccountMailing() {
// add the company address on the payment stub (2)
$this->SetFont('times','B', 10);
if($this->billToCompany && !empty($this->account['company']))
$name = $this->account['company'];
else
$name = $this->account['first_name'].' '.$this->account['last_name'];
$this->SetXY(120,240); $this->Cell(10,10, html_entity_decode($name,ENT_NOQUOTES));
$this->SetXY(120,244); $this->Cell(50,10, $this->account['address1'] .' '. $this->account['address2']);
$this->SetXY(120,248); $this->Cell(50,10, $this->account['city'] . ", ". $this->account['state'] . " " . $this->account['zip']);
}
function drawAccountId() {
$this->SetFont('times','B',11);
$this->SetXY(28, 39.5);
$this->Cell(10,10, $this->account['id']); // add to top of invoice
}
function drawAccountName() {
$this->SetFont('times','B',11);
$this->SetXY(36, 44);
if($this->billToCompany && !empty($this->account['company']))
$this->Cell(10,10, html_entity_decode($this->account['company'],ENT_NOQUOTES));
else
$this->Cell(10,10, html_entity_decode($this->account['first_name'].' '.$this->account['last_name'],ENT_NOQUOTES));
}
function drawAccountUsername() {
$this->SetFont('times','B',11);
$this->SetXY(161, 44);
$this->Cell(10,10, $this->account['username']);
}
function drawAccountAddress() {
$this->SetFont('times','B',11);
}
function drawInvoiceNo() {
$this->SetFont('times','',11);
$this->SetXY(180, 222);
$this->Cell(10,10, $this->invoice["id"]); // draw at the bottom of invoice
}
function drawInvoiceRange() {
if($this->show_service_range) {
global $C_translate;
$this->SetFont('times','B',11);
$this->SetXY(8,85.5);
$this->Cell(50,10, $C_translate->translate('pdf_service_range_month','setup_invoice') . " {$this->dateRange}");
}
}
function drawInvoiceDueDate() {
$this->SetFont('times','B',11);
$this->SetXY(161, 39.5);
$this->Cell(10,10, date(UNIX_DATE_FORMAT, $this->invoice['due_date'])); // draw at top of invoice
$this->SetFont('times','',11);
$this->SetXY(151, 222);
$this->Cell(10,10, date(UNIX_DATE_FORMAT, $this->invoice['due_date']),0,0,'C'); // draw at the bottom of invoice
}
function drawInvoiceTotalAmt() {
$this->SetXY(147.5,72);
$this->Cell(10,10, $this->_currency($this->invoice['total_amt']),0,0,'C'); // draw at the top
}
function drawInvoicePaidAmt() {
$this->SetFont('times','',11);
$this->SetXY(47,72);
$this->Cell(10,10, $this->_currency($this->invoice['billed_amt']), 0,0,'C');
}
function drawInvoiceDueAmt() {
$this->SetFont('times','',11);
$this->SetXY(114,72);
$this->Cell(10,10, $this->_currency($this->invoiceDueAmt),0,0,'C'); // draw at the top
$this->SetXY(181,72);
$this->Cell(10,10, $this->_currency($this->invoiceDueAmt),0,0,'C'); // draw at the top
$this->SetXY(123, 222);
$this->Cell(10,10, $this->_currency($this->invoiceDueAmt),0,0,'C'); // draw at the bottom
}
function drawInvoiceDiscountAmt() {
$this->SetXY(80.5, 72);
$this->Cell(10,10, $this->_currency($this->invoice['discount_amt']), 0,0,'C');
}
function drawInvoiceTaxAmt() {
$this->SetFont('times','',11);
$this->SetXY(16,72);
$this->Cell(10,10, $this->_currency($this->invoice['tax_amt']),0,0,'C'); // draw at the top
}
/**
* Called before begining to loop the invoice_item table. Used to set initial values.
*/
function drawLineItems_pre($iteration) {
$this->iteration = $iteration;
if($iteration>0)
return false;
$this->i = 0;
$this->y = 0;
return true;
}
/**
* Called once per line item to add to the PDF invoice.
*/
function drawSubLineItems(&$db, $line) {
global $C_translate;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('times','B',12);
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_itemized_charges','setup_invoice'));
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('times','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
$this->SetX(170);
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
$this->SetFont('times','',8);
$this->SetX(18);
$this->Cell(0,0, $line);
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
/**
* Called once per line item to add to the PDF invoice.
*/
function drawLineItems(&$db, &$line) {
global $C_translate;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('times','B',12);
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_itemized_charges','setup_invoice'));
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('times','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
$this->SetX(170);
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
$this->SetFont('times','',8);
$this->SetX(9);
$this->Cell(0,0, $line['name']);
$this->SetX(170);
$this->Cell(10,0, $this->_currency($line['amount']/$line['qty']),0,0,'R');
$this->SetX(145);
$this->Cell(10,0, $line['qty'],0,0,'R');
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$this->y += 5;
$this->SetY($this->y);
$this->i++;
# Draw attributes if they are present
if (strlen($line['attr'])) {
$atrs = split("\r\n", str_replace('\r\n',"\r\n",$line['attr']));
foreach ($atrs as $a) {
$parts = split("==", $a);
switch ($parts[0]) {
default:
if(strlen($parts[0]))
$this->drawSubLineItems($db, $parts[0].": ".$parts[1]);
break;
}
}
}
}
function drawSummaryLineItems($items) {
global $C_translate;
if (!$this->show_itemized) return;
$y = 105;
$this->SetY($y);
$this->SetFont('times','',11);
$i=0;
if(is_array($items)) {
foreach($items as $line) {
$val = $line['name'];
$this->SetX(9);
$this->Cell(0,0, $val);
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$y += 5;
$this->SetY($y);
$i++;
if($i > $this->itemsSummaryMax) {
$this->SetFont('times','B',11);
$this->SetX(9);
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
break;
}
}
}
}
}
?>

View File

@@ -0,0 +1,406 @@
<?php
/*
AgileVoice - Highly detailed PDF invoice
(C) 2006 Agileco LLC. All rights reserved.
$Id:$
*/
require_once PATH_INCLUDES.'pdf/invoice_base.inc.php';
class pdf_invoice_overview extends pdf_invoice_base
{
var $billToCompany = true;
var $invoiceDueAmt = 0;
var $invoiceCurrency = '$';
var $invoiceDecimals = '5';
var $itemsSummary;
var $itemsSummaryMax=16;
var $itemsFull;
var $news = 'News you can use!\n\n';
var $v, $i, $y;
var $pageType = 2;
var $show_itemized = 1;
function getTemplate() {
if ($this->pageType == 2)
return PATH_INCLUDES."pdf/invoice2.pdf";
return PATH_INCLUDES."pdf/invoice1.pdf";
}
// draw the logo
function drawCompanyLogo() {
$x = 9;
$y = 7;
$width = 50;
if(is_file(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png'))
$this->Image(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png',$x,$y,$width);
}
// draw the company address
function drawCompanyAddress() {
global $C_translate;
// add the company address on the payment stub (1)
$this->SetFont('arial','B', 13);
$this->SetXY(18,202); $this->Cell(0,0,$C_translate->translate('pdf_payment_coupon','setup_invoice'));
$this->SetFont('arial','', 8);
$this->SetXY(18,206); $this->Cell(0,0,$C_translate->translate('pdf_return1','setup_invoice'));
$this->SetXY(18,209); $this->Cell(0,0,$C_translate->translate('pdf_return2','setup_invoice').$this->companyName);
$this->SetFont('arial','', 10);
$x = 18; $y = 216;
if ($this->pageType == 2) {
$y = 230;
}
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyName); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyAddress); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyCity. ", ". $this->companyState . " " . $this->companyZip); $y += 4;
}
function drawAccountMailing() {
// add the company address on the payment stub (2)
$this->SetFont('arial','B', 10);
if($this->billToCompany && !empty($this->account['company']))
$name = $this->account['company'];
else
$name = $this->account['first_name'].' '.$this->account['last_name'];
$x = 110; $y = 248;
if ($this->pageType == 2) {
$x = 18; $y = 268;
}
$this->SetXY($x,$y); $this->Cell(0,0, html_entity_decode($name,ENT_NOQUOTES)); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['address1'] .' '. $this->account['address2']); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['city'] . ", ". $this->account['state'] . " " . $this->account['zip']); $y += 4;
}
function drawAccountId() {
global $C_translate;
$this->SetFont('arial','',11);
$this->SetXY(110, 205); $this->Cell(0,0,$C_translate->translate('pdf_account_number','setup_invoice'));
$this->SetXY(150, 205);
$this->Cell(0,0, $this->account['id']); // add to bottom of invoice
}
function drawAccountUsername() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 18); $this->Cell(0,0,$C_translate->translate('pdf_account_username','setup_invoice'));
$this->SetXY(201,18); $this->Cell(0,0,$this->account['username'],0,0,'R');
$this->SetFont('arial','',11);
$this->SetXY(95,30);
$contact = $C_translate->translate('pdf_contact','setup_invoice')."\n";
$contact .= $C_translate->translate('pdf_contact_online','setup_invoice').$this->contact_us_url."\n";
$contact .= $C_translate->translate('pdf_contact_phone','setup_invoice').$this->contact_us_phone;
$this->MultiCell(0,4,$contact);
$this->SetXY(9,170);
$this->MultiCell(0, 4, str_replace('\n',"\n",$this->news));
}
function drawAccountAddress() {
$this->SetFont('times','B',11);
}
function drawInvoiceNo() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 14); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(201, 14); $this->Cell(0,0, $this->invoice['id'],0,0,'R'); // add to bottom of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 210); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(150, 210); $this->Cell(0,0, $this->invoice['id']); // add to bottom of invoice
}
function drawInvoiceDueDate() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95,10); $this->Cell(0,0,$C_translate->translate('pdf_billing_date','setup_invoice'));
$this->SetXY(201,10); $this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date']),0,0,'R'); // draw at top of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 200); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice'));
$this->SetXY(150, 200);
$this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date'])); // draw at the bottom of invoice
}
function drawInvoiceTotalAmt() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 22); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 22); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
$this->SetFont('arial','',9);
$this->SetXY(110, 222); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 222); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
}
function drawInvoiceDueAmt() {
global $C_translate;
$this->SetFont('times','',11);
$this->SetFont('arial','',9);
$this->SetXY(110, 226); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice').date(UNIX_DATE_FORMAT, $this->invoice['due_date']));
$this->SetXY(201, 226); $this->Cell(0,0, $this->_currency($this->invoiceDueAmt),0,0,'R');
$this->SetXY(110, 230); $this->Cell(0,0,$C_translate->translate('pdf_make_check','setup_invoice'));
$this->SetXY(110, 234); $this->Cell(0,0,$this->companyName);
}
/**
* Called before begining to loop the invoice_item table. Used to set initial values.
*/
function drawLineItems_pre($iteration) {
$this->iteration = $iteration;
if($iteration>1)
return false;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$this->v = new voip;
$this->i = 0;
$this->y = 0;
return true;
}
/**
* Called once per line item to add to the PDF invoice. This function serves to
* direct each iteration to a different function which handles a specific piece
* of the PDF building puzzle.
*/
function drawLineItems(&$db, &$line) {
switch($this->iteration) {
case 0:
$this->drawLineItems_0($db, $line);
break;
case 1:
$this->drawLineItems_1($db, $line);
break;
default:
echo 'Unknown PDF iteration encountered. Halting.';
exit;
}
}
/**
* Draws the non-VoIP related items for iteration 0.
*/
function drawLineItems_0(&$db, &$line) {
global $C_translate;
if ($line['price_type'] == 0 && $line['item_type']==5)
return;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('arial','B',12);
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_itemized_charges','setup_invoice'));
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('arial','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_description','setup_invoice'));
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_quantity','setup_invoice'));
$this->SetX(170);
$this->Cell(10,0,$C_translate->translate('pdf_item_cost','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
$this->SetFont('arial','',8);
$this->SetX(9);
$this->Cell(0,0, $line['name']);
$this->SetX(170);
$this->Cell(10,0, $this->_currency($line['price_base']),0,0,'R');
$this->SetX(145);
$this->Cell(10,0, $line['qty'],0,0,'R');
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['total_amt']), 0,0,'R');
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
/**
* Draws the VoIP Calling Detail for Iteration 1.
*/
function drawLineItems_1(&$db, &$line) {
global $C_translate;
if($this->show_itemized != 1) return;
if($line['price_type'] != 0 || $line['item_type'] != 5)
return;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('arial','B',12);
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_itemized_calls','setup_invoice'));
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('arial','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_from','setup_invoice'));
$this->SetX(69);
$this->Cell(0,0,$C_translate->translate('pdf_item_to','setup_invoice'));
$this->SetX(119);
$this->Cell(0,0,'Date & Time');
$this->SetX(160);
$this->Cell(10,0,'Seconds' /*$C_translate->translate('pdf_item_min','setup_invoice')*/,0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
if ($line['price_type'] != 0) {
$this->SetFont('arial','I',6);
} else {
$this->SetFont('arial','',6);
}
$val = $line['name'];
if (strlen($line['attr'])) {
$val = "";
$atrs = split("\r\n", str_replace('\r\n',"\r\n",$line['attr']));
foreach ($atrs as $a) {
$parts = split("==", $a);
switch ($parts[0]) {
case "Destination":
$this->SetX(69);
$this->Cell(0,0,$parts[1]);
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
$this->SetX(89);
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
}
break;
case "Source":
$this->SetX(9);
$this->Cell(0,0,$parts[1]);
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
$this->SetX(29);
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
}
break;
case "parent_service_id":
$sql = sqlSelect($db,"service","prod_attr","id=::".$parts[1]."::");
$rstmp = $db->Execute($sql);
$atrs2 = split("\r\n", $rstmp->fields['prod_attr']);
foreach ($atrs2 as $a2) {
$parts2 = split("==", $a2);
switch ($parts2[0]) {
case "station":
case "ported":
$val = $line['name']." for ".$parts2[1];
break;
default:
break;
}
}
break;
case "station":
case "ported":
$val = $line['name']." for ".$parts[1];
break;
case "date_orig":
$this->SetX(119);
$this->Cell(0,0,date(UNIX_DATE_FORMAT." H:i:s",$parts[1]));
break;
case "voip_cdr_id":
$sql = "SELECT billsec, amount FROM ".AGILE_DB_PREFIX."voip_cdr WHERE site_id=".DEFAULT_SITE." AND id=".$parts[1];
$row = $db->GetRow($sql);
$this->SetX(160);
$this->Cell(10,0,$row[0],0,0,'R');
$this->SetX(160);
$this->Cell(0,0,$this->_currency($row[1]),0,0,'R');
$val = "";
default:
break;
}
}
}
$this->SetX(9);
$this->Cell(0,0, $val);
if ($line['price_type'] == 0) {
$this->SetX(160);
//$this->Cell(10,0, $line['qty']." M",0,0,'R');
} else {
$q = $line['qty'];
if(empty($q)) $q = 1;
$this->SetX(160);
$this->Cell(10,0, $line['qty'],0,0,'R');
// }
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
}
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
function drawSummaryLineItems($items) {
global $C_translate;
#if (!$this->show_itemized) return;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$v = new voip;
$db = &DB();
$this->SetFont('arial','B',11);
$y = 70;
$this->SetY($y);
$this->SetX(9); $this->Cell(0,0,$C_translate->translate('pdf_cur_charge_summary','setup_invoice').$this->dateRange);
$y += 5;
$this->SetY($y);
$this->SetFont('arial','',9);
$i=0;
if(is_array($items)) {
foreach($items as $line) {
$val = $line['name'];
$this->SetX(9);
if (@$line['item_type'] == 5) {
$val = $line['quantity'].$C_translate->translate('pdf_combine_minutes','setup_invoice');
}
$q = $line['quantity'];
if(empty($q)) $q = 1;
$this->Cell(0,0, $q);
$this->SetX(18);
$this->Cell(0,0, $val);
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$y += 5;
$this->SetY($y);
$i++;
if($i > $this->itemsSummaryMax) {
$this->SetFont('arial','B',11);
$this->SetX(9);
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
break;
}
}
}
}
}
?>

View File

@@ -0,0 +1,321 @@
<?php
/*
AgileVoice - Detailed PDF invoice with CDR detail
(C) 2006 Agileco LLC. All rights reserved.
$Id:$
*/
require_once PATH_INCLUDES.'pdf/invoice_base.inc.php';
class pdf_invoice_overview extends pdf_invoice_base
{
var $billToCompany = true;
var $invoiceDueAmt = 0;
var $invoiceCurrency = '$';
var $invoiceDecimals = '5';
var $itemsSummary;
var $itemsSummaryMax=16;
var $itemsFull;
var $news = '';
var $v, $i, $y;
var $pageType = 2;
var $show_itemized = 1;
function getTemplate() {
if ($this->pageType == 2)
return PATH_INCLUDES."pdf/invoice2.pdf";
return PATH_INCLUDES."pdf/invoice1.pdf";
}
// draw the logo
function drawCompanyLogo() {
$x = 9;
$y = 7;
$width = 50;
if(is_file(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png'))
$this->Image(PATH_THEMES.DEFAULT_THEME.'/images/invoice_logo.png',$x,$y,$width);
}
// draw the company address
function drawCompanyAddress() {
global $C_translate;
// add the company address on the payment stub (1)
$this->SetFont('arial','B', 13);
$this->SetXY(18,202); $this->Cell(0,0,$C_translate->translate('pdf_payment_coupon','setup_invoice'));
$this->SetFont('arial','', 8);
$this->SetXY(18,206); $this->Cell(0,0,$C_translate->translate('pdf_return1','setup_invoice'));
$this->SetXY(18,209); $this->Cell(0,0,$C_translate->translate('pdf_return2','setup_invoice').$this->companyName);
$this->SetFont('arial','', 10);
$x = 18; $y = 216;
if ($this->pageType == 2) {
$y = 230;
}
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyName); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyAddress); $y += 4;
$this->SetXY(18,$y); $this->Cell(0,0, $this->companyCity. ", ". $this->companyState . " " . $this->companyZip); $y += 4;
}
function drawAccountMailing() {
// add the company address on the payment stub (2)
$this->SetFont('arial','B', 10);
if($this->billToCompany && !empty($this->account['company']))
$name = $this->account['company'];
else
$name = $this->account['first_name'].' '.$this->account['last_name'];
$x = 110; $y = 248;
if ($this->pageType == 2) {
$x = 18; $y = 268;
}
$this->SetXY($x,$y); $this->Cell(0,0, html_entity_decode($name,ENT_NOQUOTES)); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['address1'] .' '. $this->account['address2']); $y += 4;
$this->SetXY($x,$y); $this->Cell(0,0, $this->account['city'] . ", ". $this->account['state'] . " " . $this->account['zip']); $y += 4;
}
function drawAccountId() {
global $C_translate;
$this->SetFont('arial','',11);
$this->SetXY(110, 205); $this->Cell(0,0,$C_translate->translate('pdf_account_number','setup_invoice'));
$this->SetXY(150, 205);
$this->Cell(0,0, $this->account['id']); // add to bottom of invoice
}
function drawAccountUsername() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 18); $this->Cell(0,0,$C_translate->translate('pdf_account_username','setup_invoice'));
$this->SetXY(201,18); $this->Cell(0,0,$this->account['username'],0,0,'R');
$this->SetFont('arial','',11);
$this->SetXY(95,30);
$contact = $C_translate->translate('pdf_contact','setup_invoice')."\n";
$contact .= $C_translate->translate('pdf_contact_online','setup_invoice').$this->contact_us_url."\n";
$contact .= $C_translate->translate('pdf_contact_phone','setup_invoice').$this->contact_us_phone;
$this->MultiCell(0,4,$contact);
$this->SetXY(9,170);
$this->MultiCell(0, 4, str_replace('\n',"\n",$this->news));
}
function drawAccountAddress() {
$this->SetFont('times','B',11);
}
function drawInvoiceNo() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 14); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(201, 14); $this->Cell(0,0, $this->invoice['id'],0,0,'R'); // add to bottom of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 210); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number','setup_invoice'));
$this->SetXY(150, 210); $this->Cell(0,0, $this->invoice['id']); // add to bottom of invoice
}
function drawInvoiceDueDate() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95,10); $this->Cell(0,0,$C_translate->translate('pdf_billing_date','setup_invoice'));
$this->SetXY(201,10); $this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date']),0,0,'R'); // draw at top of invoice
$this->SetFont('arial','',11);
$this->SetXY(110, 200); $this->Cell(0,0,$C_translate->translate('pdf_bill_date','setup_invoice'));
$this->SetXY(150, 200);
$this->Cell(0,0, date(UNIX_DATE_FORMAT, $this->invoice['due_date'])); // draw at the bottom of invoice
}
function drawInvoiceTotalAmt() {
global $C_translate;
$this->SetFont('arial','B',11);
$this->SetXY(95, 22); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 22); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
$this->SetFont('arial','',9);
$this->SetXY(110, 222); $this->Cell(0,0,$C_translate->translate('pdf_current_charges','setup_invoice'));
$this->SetXY(201, 222); $this->Cell(0,0, $this->_currency($this->invoice['total_amt']),0,0,'R'); // draw at the top
}
function drawInvoiceDueAmt() {
global $C_translate;
$this->SetFont('times','',11);
$this->SetFont('arial','',9);
$this->SetXY(110, 226); $this->Cell(0,0,$C_translate->translate('pdf_amount_due_by','setup_invoice').date(UNIX_DATE_FORMAT, $this->invoice['due_date']));
$this->SetXY(201, 226); $this->Cell(0,0, $this->_currency($this->invoiceDueAmt),0,0,'R');
$this->SetXY(110, 230); $this->Cell(0,0,$C_translate->translate('pdf_make_check','setup_invoice'));
$this->SetXY(110, 234); $this->Cell(0,0,$this->companyName);
}
/**
* Called before begining to loop the invoice_item table. Used to set initial values.
*/
function drawLineItems_pre($iteration) {
$this->iteration = $iteration;
if($iteration>0)
return false;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$this->v = new voip;
$this->i = 0;
$this->y = 0;
return true;
}
/**
* Called once per line item to add to the PDF invoice.
*/
function drawLineItems(&$db, &$line) {
global $C_translate;
if ($this->i == 0 || $this->i%51 == 0) {
$this->AddPage();
$this->SetFont('arial','B',12);
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_itemized_calls','setup_invoice'));
$this->Cell(0,0,$C_translate->translate('pdf_page','setup_invoice').$this->PageNo(),0,0,'R');
$this->SetXY(3,10); $this->Cell(0,0,$C_translate->translate('pdf_invoice_number_small','setup_invoice').$this->invoice['id'],0,0,'C');
# Draw table headers
$this->SetFont('arial','B',8);
$this->SetXY(9,20);
$this->Cell(0,0,$C_translate->translate('pdf_item_from','setup_invoice'));
$this->SetX(75);
$this->Cell(0,0,$C_translate->translate('pdf_item_to','setup_invoice'));
$this->SetX(160);
$this->Cell(10,0,$C_translate->translate('pdf_item_min','setup_invoice'),0,0,'R');
$this->SetX(145);
$this->Cell(0,0,$C_translate->translate('pdf_item_amount','setup_invoice'),0,0,'R');
$this->Line(9,21,200,21);
$this->y = 24;
$this->SetY($this->y);
}
if ($line['price_type'] != 0) {
$this->SetFont('arial','I',8);
} else {
$this->SetFont('arial','',8);
}
$val = $line['name'];
if (strlen($line['attr'])) {
$val = "";
$atrs = split("\r\n", str_replace('\r\n',"\r\n",$line['attr']));
foreach ($atrs as $a) {
$parts = split("==", $a);
switch ($parts[0]) {
case "Destination":
$this->SetX(75);
$this->Cell(0,0,$parts[1]);
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
$this->SetX(115);
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
}
break;
case "Source":
$this->SetX(9);
$this->Cell(0,0,$parts[1]);
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
if ($this->v->e164($parts[1], $e164, $cc, $npa, $nxx)) {
$this->SetX(39);
$this->Cell(0,0,substr($this->v->where_is($db, $cc, $npa, $nxx), 0, 20));
}
break;
case "parent_service_id":
$sql = sqlSelect($db,"service","prod_attr","id=::".$parts[1]."::");
$rstmp = $db->Execute($sql);
$atrs2 = split("\r\n", $rstmp->fields['prod_attr']);
foreach ($atrs2 as $a2) {
$parts2 = split("==", $a2);
switch ($parts2[0]) {
case "station":
case "ported":
$val = $line['name']." for ".$parts2[1];
break;
default:
break;
}
}
break;
case "station":
case "ported":
$val = $line['name']." for ".$parts[1];
break;
default:
break;
}
}
}
$this->SetX(9);
$this->Cell(0,0, $val);
if ($line['price_type'] == 0) {
$this->SetX(160);
$this->Cell(10,0, $line['qty']." M",0,0,'R');
} else {
$q = $line['qty'];
if(empty($q)) $q = 1;
$this->SetX(160);
$this->Cell(10,0, $line['qty'],0,0,'R');
}
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['total_amt']), 0,0,'R');
$this->y += 5;
$this->SetY($this->y);
$this->i++;
}
function drawSummaryLineItems($items) {
global $C_translate;
if (!$this->show_itemized) return;
# Include the voip class
include_once(PATH_MODULES.'voip/voip.inc.php');
$v = new voip;
$db = &DB();
$this->SetFont('arial','B',11);
$y = 70;
$this->SetY($y);
$this->SetX(9); $this->Cell(0,0,$C_translate->translate('pdf_cur_charge_summary','setup_invoice').$this->dateRange);
$y += 5;
$this->SetY($y);
$this->SetFont('arial','',9);
$i=0;
if(is_array($items)) {
foreach($items as $line) {
$val = $line['name'];
$this->SetX(9);
if (@$line['item_type'] == 5) {
$val = $line['quantity'].$C_translate->translate('pdf_combine_minutes','setup_invoice');
}
$q = $line['quantity'];
if(empty($q)) $q = 1;
$this->Cell(0,0, $q);
$this->SetX(18);
$this->Cell(0,0, $val);
$this->SetX(145);
$this->Cell(0,0, $this->_currency($line['amount']), 0,0,'R');
$y += 5;
$this->SetY($y);
$i++;
if($i > $this->itemsSummaryMax) {
$this->SetFont('arial','B',11);
$this->SetX(9);
$this->Cell(0,0,$C_translate->translate('pdf_summary','setup_invoice'));
break;
}
}
}
}
}
?>

634
includes/pdf/pdf_parser.php Normal file
View File

@@ -0,0 +1,634 @@
<?php
//
// FPDI - Version 1.1
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
if (!defined ('PDF_TYPE_NULL'))
define ('PDF_TYPE_NULL', 0);
if (!defined ('PDF_TYPE_NUMERIC'))
define ('PDF_TYPE_NUMERIC', 1);
if (!defined ('PDF_TYPE_TOKEN'))
define ('PDF_TYPE_TOKEN', 2);
if (!defined ('PDF_TYPE_HEX'))
define ('PDF_TYPE_HEX', 3);
if (!defined ('PDF_TYPE_STRING'))
define ('PDF_TYPE_STRING', 4);
if (!defined ('PDF_TYPE_DICTIONARY'))
define ('PDF_TYPE_DICTIONARY', 5);
if (!defined ('PDF_TYPE_ARRAY'))
define ('PDF_TYPE_ARRAY', 6);
if (!defined ('PDF_TYPE_OBJDEC'))
define ('PDF_TYPE_OBJDEC', 7);
if (!defined ('PDF_TYPE_OBJREF'))
define ('PDF_TYPE_OBJREF', 8);
if (!defined ('PDF_TYPE_OBJECT'))
define ('PDF_TYPE_OBJECT', 9);
if (!defined ('PDF_TYPE_STREAM'))
define ('PDF_TYPE_STREAM', 10);
require_once("pdf_context.php");
class pdf_parser {
/**
* Filename
* @var string
*/
var $filename;
/**
* File resource
* @var resource
*/
var $f;
/**
* PDF Context
* @var object pdf_context-Instance
*/
var $c;
/**
* xref-Data
* @var array
*/
var $xref;
/**
* root-Object
* @var array
*/
var $root;
/**
* Constructor
*
* @param string $filename Source-Filename
*/
function pdf_parser($filename) {
$this->filename = $filename;
$this->f = @fopen($this->filename,"rb");
if (!$this->f)
$this->error(sprintf("Cannot open %s !",$filename));
$this->getPDFVersion();
$this->c = new pdf_context($this->f);
// Read xref-Data
$this->pdf_read_xref($this->xref, $this->pdf_find_xref());
// Check for Encryption
$this->getEncryption();
// Read root
$this->pdf_read_root();
}
/**
* Close the opened file
*/
function closeFile() {
if (isset($this->f)) {
fclose($this->f);
}
}
/**
* Print Error and die
*
* @param string $msg Error-Message
*/
function error($msg) {
die("<b>PDF-Parser Error:</b> ".$msg);
}
/**
* Check Trailer for Encryption
*/
function getEncryption() {
if (isset($this->xref['trailer'][1]['/Encrypt'])) {
$this->error("File is encrypted!");
}
}
/**
* Find/Return /Root
*
* @return array
*/
function pdf_find_root() {
if ($this->xref['trailer'][1]['/Root'][0] != PDF_TYPE_OBJREF) {
$this->Error("Wrong Type of Root-Element! Must be an indirect reference");
}
return $this->xref['trailer'][1]['/Root'];
}
/**
* Read the /Root
*/
function pdf_read_root() {
// read root
$this->root = $this->pdf_resolve_object($this->c, $this->pdf_find_root());
}
/**
* Get PDF-Version
*
* And reset the PDF Version used in FPDI if needed
*/
function getPDFVersion() {
fseek($this->f, 0);
preg_match("/\d\.\d/",fread($this->f,16),$m);
$this->pdfVersion = $m[0];
}
/**
* Find the xref-Table
*/
function pdf_find_xref() {
fseek ($this->f, -50, SEEK_END);
$data = fread($this->f, 50);
if (!preg_match('/startxref\s*(\d+)\s*%%EOF\s*$/', $data, $matches)) {
$this->error("Unable to find pointer to xref table");
}
return (int) $matches[1];
}
/**
* Read xref-table
*
* @param array $result Array of xref-table
* @param integer $offset of xref-table
* @param integer $start start-position in xref-table
* @param integer $end end-position in xref-table
*/
function pdf_read_xref(&$result, $offset, $start = null, $end = null) {
if (is_null ($start) || is_null ($end)) {
fseek($this->f, $o_pos = $offset);
$data = trim(fgets($this->f));
if ($data !== 'xref') {
fseek($this->f, $o_pos);
$data = trim(_fgets($this->f, true));
if ($data !== 'xref') {
$this->error("Unable to find xref table - Maybe a Problem with 'auto_detect_line_endings'");
}
}
$o_pos = ftell($this->f);
$data = explode(' ', trim(fgets($this->f)));
if (count($data) != 2) {
fseek($this->f, $o_pos);
$data = explode(' ', trim(_fgets($this->f, true)));
if (count($data) != 2)
$this->error("Unexpected header in xref table");
}
$start = $data[0];
$end = $start + $data[1];
}
if (!isset($result['xref_location'])) {
$result['xref_location'] = $offset;
}
if (!isset($result['max_object']) || $end > $result['max_object']) {
$result['max_object'] = $end;
}
for (; $start < $end; $start++) {
$data = fread($this->f, 20); // Spezifications says: 20 bytes including newlines
$offset = substr($data, 0, 10);
$generation = substr($data, 11, 5);
if (!isset ($result['xref'][$start][(int) $generation])) {
$result['xref'][$start][(int) $generation] = (int) $offset;
}
}
$o_pos = ftell($this->f);
$data = fgets($this->f);
if (preg_match("/trailer/",$data)) {
if (preg_match("/(.*trailer[ \n\r]+)/",$data,$m)) {
fseek($this->f, $o_pos+strlen($m[1]));
}
$c =& new pdf_context($this->f);
$trailer = $this->pdf_read_value($c);
if (isset($trailer[1]['/Prev'])) {
$this->pdf_read_xref($result, $trailer[1]['/Prev'][1]);
$result['trailer'][1] = array_merge($result['trailer'][1], $trailer[1]);
} else {
$result['trailer'] = $trailer;
}
} else {
$data = explode(' ', trim($data));
if (count($data) != 2) {
fseek($this->f, $o_pos);
$data = explode(' ', trim (_fgets ($this->f, true)));
if (count($data) != 2) {
$this->error("Unexpected data in xref table");
}
}
$this->pdf_read_xref($result, null, (int) $data[0], (int) $data[0] + (int) $data[1]);
}
}
/**
* Reads an Value
*
* @param object $c pdf_context
* @param string $token a Token
* @return mixed
*/
function pdf_read_value(&$c, $token = null) {
if (is_null($token)) {
$token = $this->pdf_read_token($c);
}
if ($token === false) {
return false;
}
switch ($token) {
case '<':
// This is a hex string.
// Read the value, then the terminator
$pos = $c->offset;
while(1) {
$match = strpos ($c->buffer, '>', $pos);
// If you can't find it, try
// reading more data from the stream
if ($match === false) {
if (!$c->increase_length()) {
return false;
} else {
continue;
}
}
$result = substr ($c->buffer, $c->offset, $match - $c->offset);
$c->offset = $match+1;
return array (PDF_TYPE_HEX, $result);
}
break;
case '<<':
// This is a dictionary.
$result = array();
// Recurse into this function until we reach
// the end of the dictionary.
while (($key = $this->pdf_read_token($c)) !== '>>') {
if ($key === false) {
return false;
}
if (($value = $this->pdf_read_value($c)) === false) {
return false;
}
$result[$key] = $value;
}
return array (PDF_TYPE_DICTIONARY, $result);
case '[':
// This is an array.
$result = array();
// Recurse into this function until we reach
// the end of the array.
while (($token = $this->pdf_read_token($c)) !== ']') {
if ($token === false) {
return false;
}
if (($value = $this->pdf_read_value($c, $token)) === false) {
return false;
}
$result[] = $value;
}
return array (PDF_TYPE_ARRAY, $result);
case '(' :
// This is a string
$pos = $c->offset;
while(1) {
// Start by finding the next closed
// parenthesis
$match = strpos ($c->buffer, ')', $pos);
// If you can't find it, try
// reading more data from the stream
if ($match === false) {
if (!$c->increase_length()) {
return false;
} else {
continue;
}
}
// Make sure that there is no backslash
// before the parenthesis. If there is,
// move on. Otherwise, return the string.
if (isset($c->buffer[$match - 1]) && $c->buffer[$match - 1] !== '\\' ||
isset($c->buffer[$match - 1]) && $c->buffer[$match - 1] === '\\' && isset($c->buffer[$match - 2]) && $c->buffer[$match - 2] === '\\') {
$result = substr ($c->buffer, $c->offset, $match - $c->offset);
$c->offset = $match + 1;
return array (PDF_TYPE_STRING, $result);
} else {
$pos = $match + 1;
if ($pos > $c->offset + $c->length) {
$c->increase_length();
}
}
}
case "stream":
$o_pos = ftell($c->file)-strlen($c->buffer);
$o_offset = $c->offset;
$c->reset($startpos = $o_pos + $o_offset);
$e = 0; // ensure line breaks in front of the stream
if ($c->buffer[0] == chr(10) || $c->buffer[0] == chr(13))
$e++;
if ($c->buffer[1] == chr(10) && $c->buffer[0] != chr(10))
$e++;
if ($this->actual_obj[1][1]['/Length'][0] == PDF_TYPE_OBJREF) {
$tmp_c = new pdf_context($this->f);
$tmp_length = $this->pdf_resolve_object($tmp_c,$this->actual_obj[1][1]['/Length']);
$length = $tmp_length[1][1];
} else {
$length = $this->actual_obj[1][1]['/Length'][1];
}
$c->reset($startpos+$e,$length);
$v = $c->buffer;
$c->reset($startpos+$e+$length+strlen("endstream"));
return array(PDF_TYPE_STREAM, $v);
default :
if (is_numeric ($token)) {
// A numeric token. Make sure that
// it is not part of something else.
if (($tok2 = $this->pdf_read_token ($c)) !== false) {
if (is_numeric ($tok2)) {
// Two numeric tokens in a row.
// In this case, we're probably in
// front of either an object reference
// or an object specification.
// Determine the case and return the data
if (($tok3 = $this->pdf_read_token ($c)) !== false) {
switch ($tok3) {
case 'obj' :
return array (PDF_TYPE_OBJDEC, (int) $token, (int) $tok2);
case 'R' :
return array (PDF_TYPE_OBJREF, (int) $token, (int) $tok2);
}
// If we get to this point, that numeric value up
// there was just a numeric value. Push the extra
// tokens back into the stack and return the value.
array_push ($c->stack, $tok3);
}
}
array_push ($c->stack, $tok2);
}
return array (PDF_TYPE_NUMERIC, $token);
} else {
// Just a token. Return it.
return array (PDF_TYPE_TOKEN, $token);
}
}
}
/**
* Resolve an object
*
* @param object $c pdf_context
* @param array $obj_spec The object-data
* @param boolean $encapsulate Must set to true, cause the parsing and fpdi use this method only without this para
*/
function pdf_resolve_object(&$c, $obj_spec, $encapsulate = true) {
// Exit if we get invalid data
if (!is_array($obj_spec)) {
return false;
}
if ($obj_spec[0] == PDF_TYPE_OBJREF) {
// This is a reference, resolve it
if (isset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]])) {
// Save current file position
// This is needed if you want to resolve
// references while you're reading another object
// (e.g.: if you need to determine the length
// of a stream)
$old_pos = ftell($c->file);
// Reposition the file pointer and
// load the object header.
$c->reset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]]);
$header = $this->pdf_read_value($c,null,true);
if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) {
$this->error("Unable to find object ({$obj_spec[1]}, {$obj_spec[2]}) at expected location");
}
// If we're being asked to store all the information
// about the object, we add the object ID and generation
// number for later use
$this->actual_obj =& $result;
if ($encapsulate) {
$result = array (
PDF_TYPE_OBJECT,
'obj' => $obj_spec[1],
'gen' => $obj_spec[2]
);
} else {
$result = array();
}
// Now simply read the object data until
// we encounter an end-of-object marker
while(1) {
$value = $this->pdf_read_value($c);
if ($value === false || count($result) > 4) {
// in this case the parser coudn't find an endobj so we break here
break;
}
if ($value[0] == PDF_TYPE_TOKEN && $value[1] === 'endobj') {
break;
}
$result[] = $value;
}
$c->reset($old_pos);
if (isset($result[2][0]) && $result[2][0] == PDF_TYPE_STREAM) {
$result[0] = PDF_TYPE_STREAM;
}
return $result;
}
} else {
return $obj_spec;
}
}
/**
* Reads a token from the file
*
* @param object $c pdf_context
* @return mixed
*/
function pdf_read_token(&$c)
{
// If there is a token available
// on the stack, pop it out and
// return it.
if (count($c->stack)) {
return array_pop($c->stack);
}
// Strip away any whitespace
do {
if (!$c->ensure_content()) {
return false;
}
$c->offset += _strspn($c->buffer, " \n\r", $c->offset);
} while ($c->offset >= $c->length - 1);
// Get the first character in the stream
$char = $c->buffer[$c->offset++];
switch ($char) {
case '[' :
case ']' :
case '(' :
case ')' :
// This is either an array or literal string
// delimiter, Return it
return $char;
case '<' :
case '>' :
// This could either be a hex string or
// dictionary delimiter. Determine the
// appropriate case and return the token
if ($c->buffer[$c->offset] == $char) {
if (!$c->ensure_content()) {
return false;
}
$c->offset++;
return $char . $char;
} else {
return $char;
}
default :
// This is "another" type of token (probably
// a dictionary entry or a numeric value)
// Find the end and return it.
if (!$c->ensure_content()) {
return false;
}
while(1) {
// Determine the length of the token
$pos = _strcspn($c->buffer, " []<>()\r\n\t/", $c->offset);
if ($c->offset + $pos <= $c->length - 1) {
break;
} else {
// If the script reaches this point,
// the token may span beyond the end
// of the current buffer. Therefore,
// we increase the size of the buffer
// and try again--just to be safe.
$c->increase_length();
}
}
$result = substr($c->buffer, $c->offset - 1, $pos + 1);
$c->offset += $pos;
return $result;
}
}
}
?>

View File

@@ -0,0 +1,88 @@
<?php
//
// FPDI - Version 1.1
//
// Copyright 2004,2005 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
if (!defined("PHP_VER_LOWER43"))
define("PHP_VER_LOWER43", version_compare(PHP_VERSION, "4.3", "<"));
/**
* ensure that strspn works correct if php-version < 4.3
*/
function _strspn($str1, $str2, $start=null, $length=null) {
$numargs = func_num_args();
if (PHP_VER_LOWER43 == 1) {
if (isset($length)) {
$str1 = substr($str1, $start, $length);
} else {
$str1 = substr($str1, $start);
}
}
if ($numargs == 2 || PHP_VER_LOWER43 == 1) {
return strspn($str1, $str2);
} else if ($numargs == 3) {
return strspn($str1, $str2, $start);
} else {
return strspn($str1, $str2, $start, $length);
}
}
/**
* ensure that strcspn works correct if php-version < 4.3
*/
function _strcspn($str1, $str2, $start=null, $length=null) {
$numargs = func_num_args();
if (PHP_VER_LOWER43 == 1) {
if (isset($length)) {
$str1 = substr($str1, $start, $length);
} else {
$str1 = substr($str1, $start);
}
}
if ($numargs == 2 || PHP_VER_LOWER43 == 1) {
return strcspn($str1, $str2);
} else if ($numargs == 3) {
return strcspn($str1, $str2, $start);
} else {
return strcspn($str1, $str2, $start, $length);
}
}
/**
* ensure that fgets works correct if php-version < 4.3
*/
function _fgets (&$h, $force=false) {
$startpos = ftell($h);
$s = fgets($h, 1024);
if ((PHP_VER_LOWER43 == 1 || $force) && preg_match("/^([^\r\n]*[\r\n]{1,2})(.)/",trim($s), $ns)) {
$s = $ns[1];
fseek($h,$startpos+strlen($s));
}
return $s;
}
?>