├── fpdf ├── font │ ├── courier.php │ ├── courierb.php │ ├── courieri.php │ ├── courierbi.php │ ├── times.php │ ├── timesi.php │ ├── helvetica.php │ ├── timesb.php │ ├── helveticab.php │ ├── timesbi.php │ ├── helveticai.php │ ├── helveticabi.php │ ├── zapfdingbats.php │ └── symbol.php ├── fpdf.css └── fpdf.php ├── books.sql ├── database.php ├── README.md └── index.php /fpdf/font/courier.php: -------------------------------------------------------------------------------- 1 | array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 10 | ?> 11 | -------------------------------------------------------------------------------- /fpdf/font/courierb.php: -------------------------------------------------------------------------------- 1 | array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 10 | ?> 11 | -------------------------------------------------------------------------------- /fpdf/font/courieri.php: -------------------------------------------------------------------------------- 1 | array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 10 | ?> 11 | -------------------------------------------------------------------------------- /fpdf/font/courierbi.php: -------------------------------------------------------------------------------- 1 | array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 10 | ?> 11 | -------------------------------------------------------------------------------- /books.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Table structure for table `books` 3 | -- 4 | 5 | CREATE TABLE IF NOT EXISTS `books` ( 6 | `name` varchar(255) DEFAULT NULL, 7 | `author` varchar(255) DEFAULT NULL 8 | ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; 9 | 10 | -- 11 | -- Dumping data for table `books` 12 | -- 13 | 14 | INSERT INTO `books` (`name`,`author`) VALUES 15 | ('What young India wants', 'Chetan Bhagat'), 16 | ('Two States', 'Chetan Bhagat'), 17 | ('The hunger games', 'Suzanne Collions'), 18 | ('The 3 mistakes of my life', ' Chetan Bhagat'), 19 | ('Serious Men', ' Manu Joseph'), 20 | ('Revolution 2020', ' Chetan Bhagat'), 21 | ('God"s Little Soldier', 'Kiran Nagarkar'); 22 | -------------------------------------------------------------------------------- /database.php: -------------------------------------------------------------------------------- 1 | host,$this->user,$this->password,$this->database); 10 | if ($conn->connect_error) { 11 | die("Connection failed: " . $conn->connect_error); 12 | } 13 | $result = $conn->query($sql); 14 | if ($result->num_rows > 0) { 15 | while($row = $result->fetch_assoc()) { 16 | $resultset[] = $row; 17 | } 18 | } 19 | $conn->close(); 20 | 21 | if(!empty($resultset)) 22 | return $resultset; 23 | } 24 | } 25 | ?> -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generate-pdf-from-mysql-database-using-php 2 | 3 | The full tutorial can be foud @ http://angularcode.com/generate-pdf-using-php-mysql/ 4 | ##Import data 5 | Import books.sql into your MySQL 6 | This will create necessary tables and insert sample data into it. 7 | 8 | ##Change the settings 9 | You need to change the following database settings in **database.php** 10 |
11 |   private $host = "localhost";
12 | 	private $user = "root";
13 | 	private $password = "root";
14 | 	private $database = "crud";
15 | 
16 | 17 | ##Run the program 18 | Copy the project into your PHP servers root directory and access the index.php 19 | 20 | This should create the PDF page and display it in the browser. 21 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | runQuery("SELECT name,author FROM books"); 5 | $header = $database->runQuery("SELECT UCASE(`COLUMN_NAME`) 6 | FROM `INFORMATION_SCHEMA`.`COLUMNS` 7 | WHERE `TABLE_SCHEMA`='crud' 8 | AND `TABLE_NAME`='books' 9 | and `COLUMN_NAME` in ('name','author')"); 10 | 11 | require('fpdf/fpdf.php'); 12 | $pdf = new FPDF(); 13 | $pdf->AddPage(); 14 | $pdf->SetFont('Arial','B',16); 15 | 16 | foreach($header as $heading) { 17 | foreach($heading as $column_heading) 18 | $pdf->Cell(95,12,$column_heading,1); 19 | } 20 | foreach($result as $row) { 21 | $pdf->Ln(); 22 | foreach($row as $column) 23 | $pdf->Cell(95,12,$column,1); 24 | } 25 | $pdf->Output(); 26 | ?> -------------------------------------------------------------------------------- /fpdf/fpdf.css: -------------------------------------------------------------------------------- 1 | body {font-family:"Times New Roman",serif} 2 | h1 {font:bold 135% Arial,sans-serif; color:#4000A0; margin-bottom:0.9em} 3 | h2 {font:bold 95% Arial,sans-serif; color:#900000; margin-top:1.5em; margin-bottom:1em} 4 | dl.param dt {text-decoration:underline} 5 | dl.param dd {margin-top:1em; margin-bottom:1em} 6 | dl.param ul {margin-top:1em; margin-bottom:1em} 7 | tt, code, kbd {font-family:"Courier New",Courier,monospace; font-size:82%} 8 | div.source {margin-top:1.4em; margin-bottom:1.3em} 9 | div.source pre {display:table; border:1px solid #24246A; width:100%; margin:0em; font-family:inherit; font-size:100%} 10 | div.source code {display:block; border:1px solid #C5C5EC; background-color:#F0F5FF; padding:6px; color:#000000} 11 | div.doc-source {margin-top:1.4em; margin-bottom:1.3em} 12 | div.doc-source pre {display:table; width:100%; margin:0em; font-family:inherit; font-size:100%} 13 | div.doc-source code {display:block; background-color:#E0E0E0; padding:4px} 14 | .kw {color:#000080; font-weight:bold} 15 | .str {color:#CC0000} 16 | .cmt {color:#008000} 17 | p.demo {text-align:center; margin-top:-0.9em} 18 | a.demo {text-decoration:none; font-weight:bold; color:#0000CC} 19 | a.demo:link {text-decoration:none; font-weight:bold; color:#0000CC} 20 | a.demo:hover {text-decoration:none; font-weight:bold; color:#0000FF} 21 | a.demo:active {text-decoration:none; font-weight:bold; color:#0000FF} 22 | -------------------------------------------------------------------------------- /fpdf/font/times.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/timesi.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/helvetica.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/timesb.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/helveticab.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/timesbi.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/helveticai.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/helveticabi.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $enc = 'cp1252'; 20 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); 21 | ?> 22 | -------------------------------------------------------------------------------- /fpdf/font/zapfdingbats.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $uv = array(32=>32,33=>array(9985,4),37=>9742,38=>array(9990,4),42=>9755,43=>9758,44=>array(9996,28),72=>9733,73=>array(10025,35),108=>9679,109=>10061,110=>9632,111=>array(10063,4),115=>9650,116=>9660,117=>9670,118=>10070,119=>9687,120=>array(10072,7),128=>array(10088,14),161=>array(10081,7),168=>9827,169=>9830,170=>9829,171=>9824,172=>array(9312,10),182=>array(10102,31),213=>8594,214=>array(8596,2),216=>array(10136,24),241=>array(10161,14)); 20 | ?> 21 | -------------------------------------------------------------------------------- /fpdf/font/symbol.php: -------------------------------------------------------------------------------- 1 | 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, 8 | 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, 9 | ','=>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, 10 | '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, 11 | '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, 12 | '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, 13 | 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, 14 | 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, 15 | 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, 16 | 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, 17 | 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, 18 | 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); 19 | $uv = array(32=>160,33=>33,34=>8704,35=>35,36=>8707,37=>array(37,2),39=>8715,40=>array(40,2),42=>8727,43=>array(43,2),45=>8722,46=>array(46,18),64=>8773,65=>array(913,2),67=>935,68=>array(916,2),70=>934,71=>915,72=>919,73=>921,74=>977,75=>array(922,4),79=>array(927,2),81=>920,82=>929,83=>array(931,3),86=>962,87=>937,88=>926,89=>936,90=>918,91=>91,92=>8756,93=>93,94=>8869,95=>95,96=>63717,97=>array(945,2),99=>967,100=>array(948,2),102=>966,103=>947,104=>951,105=>953,106=>981,107=>array(954,4),111=>array(959,2),113=>952,114=>961,115=>array(963,3),118=>982,119=>969,120=>958,121=>968,122=>950,123=>array(123,3),126=>8764,160=>8364,161=>978,162=>8242,163=>8804,164=>8725,165=>8734,166=>402,167=>9827,168=>9830,169=>9829,170=>9824,171=>8596,172=>array(8592,4),176=>array(176,2),178=>8243,179=>8805,180=>215,181=>8733,182=>8706,183=>8226,184=>247,185=>array(8800,2),187=>8776,188=>8230,189=>array(63718,2),191=>8629,192=>8501,193=>8465,194=>8476,195=>8472,196=>8855,197=>8853,198=>8709,199=>array(8745,2),201=>8835,202=>8839,203=>8836,204=>8834,205=>8838,206=>array(8712,2),208=>8736,209=>8711,210=>63194,211=>63193,212=>63195,213=>8719,214=>8730,215=>8901,216=>172,217=>array(8743,2),219=>8660,220=>array(8656,4),224=>9674,225=>9001,226=>array(63720,3),229=>8721,230=>array(63723,10),241=>9002,242=>8747,243=>8992,244=>63733,245=>8993,246=>array(63734,9)); 20 | ?> 21 | -------------------------------------------------------------------------------- /fpdf/fpdf.php: -------------------------------------------------------------------------------- 1 | _dochecks(); 78 | // Initialization of properties 79 | $this->state = 0; 80 | $this->page = 0; 81 | $this->n = 2; 82 | $this->buffer = ''; 83 | $this->pages = array(); 84 | $this->PageInfo = array(); 85 | $this->fonts = array(); 86 | $this->FontFiles = array(); 87 | $this->encodings = array(); 88 | $this->cmaps = array(); 89 | $this->images = array(); 90 | $this->links = array(); 91 | $this->InHeader = false; 92 | $this->InFooter = false; 93 | $this->lasth = 0; 94 | $this->FontFamily = ''; 95 | $this->FontStyle = ''; 96 | $this->FontSizePt = 12; 97 | $this->underline = false; 98 | $this->DrawColor = '0 G'; 99 | $this->FillColor = '0 g'; 100 | $this->TextColor = '0 g'; 101 | $this->ColorFlag = false; 102 | $this->WithAlpha = false; 103 | $this->ws = 0; 104 | // Font path 105 | if(defined('FPDF_FONTPATH')) 106 | { 107 | $this->fontpath = FPDF_FONTPATH; 108 | if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') 109 | $this->fontpath .= '/'; 110 | } 111 | elseif(is_dir(dirname(__FILE__).'/font')) 112 | $this->fontpath = dirname(__FILE__).'/font/'; 113 | else 114 | $this->fontpath = ''; 115 | // Core fonts 116 | $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'); 117 | // Scale factor 118 | if($unit=='pt') 119 | $this->k = 1; 120 | elseif($unit=='mm') 121 | $this->k = 72/25.4; 122 | elseif($unit=='cm') 123 | $this->k = 72/2.54; 124 | elseif($unit=='in') 125 | $this->k = 72; 126 | else 127 | $this->Error('Incorrect unit: '.$unit); 128 | // Page sizes 129 | $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), 130 | 'letter'=>array(612,792), 'legal'=>array(612,1008)); 131 | $size = $this->_getpagesize($size); 132 | $this->DefPageSize = $size; 133 | $this->CurPageSize = $size; 134 | // Page orientation 135 | $orientation = strtolower($orientation); 136 | if($orientation=='p' || $orientation=='portrait') 137 | { 138 | $this->DefOrientation = 'P'; 139 | $this->w = $size[0]; 140 | $this->h = $size[1]; 141 | } 142 | elseif($orientation=='l' || $orientation=='landscape') 143 | { 144 | $this->DefOrientation = 'L'; 145 | $this->w = $size[1]; 146 | $this->h = $size[0]; 147 | } 148 | else 149 | $this->Error('Incorrect orientation: '.$orientation); 150 | $this->CurOrientation = $this->DefOrientation; 151 | $this->wPt = $this->w*$this->k; 152 | $this->hPt = $this->h*$this->k; 153 | // Page rotation 154 | $this->CurRotation = 0; 155 | // Page margins (1 cm) 156 | $margin = 28.35/$this->k; 157 | $this->SetMargins($margin,$margin); 158 | // Interior cell margin (1 mm) 159 | $this->cMargin = $margin/10; 160 | // Line width (0.2 mm) 161 | $this->LineWidth = .567/$this->k; 162 | // Automatic page break 163 | $this->SetAutoPageBreak(true,2*$margin); 164 | // Default display mode 165 | $this->SetDisplayMode('default'); 166 | // Enable compression 167 | $this->SetCompression(true); 168 | // Set default PDF version number 169 | $this->PDFVersion = '1.3'; 170 | } 171 | 172 | function SetMargins($left, $top, $right=null) 173 | { 174 | // Set left, top and right margins 175 | $this->lMargin = $left; 176 | $this->tMargin = $top; 177 | if($right===null) 178 | $right = $left; 179 | $this->rMargin = $right; 180 | } 181 | 182 | function SetLeftMargin($margin) 183 | { 184 | // Set left margin 185 | $this->lMargin = $margin; 186 | if($this->page>0 && $this->x<$margin) 187 | $this->x = $margin; 188 | } 189 | 190 | function SetTopMargin($margin) 191 | { 192 | // Set top margin 193 | $this->tMargin = $margin; 194 | } 195 | 196 | function SetRightMargin($margin) 197 | { 198 | // Set right margin 199 | $this->rMargin = $margin; 200 | } 201 | 202 | function SetAutoPageBreak($auto, $margin=0) 203 | { 204 | // Set auto page break mode and triggering margin 205 | $this->AutoPageBreak = $auto; 206 | $this->bMargin = $margin; 207 | $this->PageBreakTrigger = $this->h-$margin; 208 | } 209 | 210 | function SetDisplayMode($zoom, $layout='default') 211 | { 212 | // Set display mode in viewer 213 | if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) 214 | $this->ZoomMode = $zoom; 215 | else 216 | $this->Error('Incorrect zoom display mode: '.$zoom); 217 | if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') 218 | $this->LayoutMode = $layout; 219 | else 220 | $this->Error('Incorrect layout display mode: '.$layout); 221 | } 222 | 223 | function SetCompression($compress) 224 | { 225 | // Set page compression 226 | if(function_exists('gzcompress')) 227 | $this->compress = $compress; 228 | else 229 | $this->compress = false; 230 | } 231 | 232 | function SetTitle($title, $isUTF8=false) 233 | { 234 | // Title of document 235 | $this->metadata['Title'] = $isUTF8 ? $title : utf8_encode($title); 236 | } 237 | 238 | function SetAuthor($author, $isUTF8=false) 239 | { 240 | // Author of document 241 | $this->metadata['Author'] = $isUTF8 ? $author : utf8_encode($author); 242 | } 243 | 244 | function SetSubject($subject, $isUTF8=false) 245 | { 246 | // Subject of document 247 | $this->metadata['Subject'] = $isUTF8 ? $subject : utf8_encode($subject); 248 | } 249 | 250 | function SetKeywords($keywords, $isUTF8=false) 251 | { 252 | // Keywords of document 253 | $this->metadata['Keywords'] = $isUTF8 ? $keywords : utf8_encode($keywords); 254 | } 255 | 256 | function SetCreator($creator, $isUTF8=false) 257 | { 258 | // Creator of document 259 | $this->metadata['Creator'] = $isUTF8 ? $creator : utf8_encode($creator); 260 | } 261 | 262 | function AliasNbPages($alias='{nb}') 263 | { 264 | // Define an alias for total number of pages 265 | $this->AliasNbPages = $alias; 266 | } 267 | 268 | function Error($msg) 269 | { 270 | // Fatal error 271 | throw new Exception('FPDF error: '.$msg); 272 | } 273 | 274 | function Close() 275 | { 276 | // Terminate document 277 | if($this->state==3) 278 | return; 279 | if($this->page==0) 280 | $this->AddPage(); 281 | // Page footer 282 | $this->InFooter = true; 283 | $this->Footer(); 284 | $this->InFooter = false; 285 | // Close page 286 | $this->_endpage(); 287 | // Close document 288 | $this->_enddoc(); 289 | } 290 | 291 | function AddPage($orientation='', $size='', $rotation=0) 292 | { 293 | // Start a new page 294 | if($this->state==3) 295 | $this->Error('The document is closed'); 296 | $family = $this->FontFamily; 297 | $style = $this->FontStyle.($this->underline ? 'U' : ''); 298 | $fontsize = $this->FontSizePt; 299 | $lw = $this->LineWidth; 300 | $dc = $this->DrawColor; 301 | $fc = $this->FillColor; 302 | $tc = $this->TextColor; 303 | $cf = $this->ColorFlag; 304 | if($this->page>0) 305 | { 306 | // Page footer 307 | $this->InFooter = true; 308 | $this->Footer(); 309 | $this->InFooter = false; 310 | // Close page 311 | $this->_endpage(); 312 | } 313 | // Start new page 314 | $this->_beginpage($orientation,$size,$rotation); 315 | // Set line cap style to square 316 | $this->_out('2 J'); 317 | // Set line width 318 | $this->LineWidth = $lw; 319 | $this->_out(sprintf('%.2F w',$lw*$this->k)); 320 | // Set font 321 | if($family) 322 | $this->SetFont($family,$style,$fontsize); 323 | // Set colors 324 | $this->DrawColor = $dc; 325 | if($dc!='0 G') 326 | $this->_out($dc); 327 | $this->FillColor = $fc; 328 | if($fc!='0 g') 329 | $this->_out($fc); 330 | $this->TextColor = $tc; 331 | $this->ColorFlag = $cf; 332 | // Page header 333 | $this->InHeader = true; 334 | $this->Header(); 335 | $this->InHeader = false; 336 | // Restore line width 337 | if($this->LineWidth!=$lw) 338 | { 339 | $this->LineWidth = $lw; 340 | $this->_out(sprintf('%.2F w',$lw*$this->k)); 341 | } 342 | // Restore font 343 | if($family) 344 | $this->SetFont($family,$style,$fontsize); 345 | // Restore colors 346 | if($this->DrawColor!=$dc) 347 | { 348 | $this->DrawColor = $dc; 349 | $this->_out($dc); 350 | } 351 | if($this->FillColor!=$fc) 352 | { 353 | $this->FillColor = $fc; 354 | $this->_out($fc); 355 | } 356 | $this->TextColor = $tc; 357 | $this->ColorFlag = $cf; 358 | } 359 | 360 | function Header() 361 | { 362 | // To be implemented in your own inherited class 363 | } 364 | 365 | function Footer() 366 | { 367 | // To be implemented in your own inherited class 368 | } 369 | 370 | function PageNo() 371 | { 372 | // Get current page number 373 | return $this->page; 374 | } 375 | 376 | function SetDrawColor($r, $g=null, $b=null) 377 | { 378 | // Set color for all stroking operations 379 | if(($r==0 && $g==0 && $b==0) || $g===null) 380 | $this->DrawColor = sprintf('%.3F G',$r/255); 381 | else 382 | $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); 383 | if($this->page>0) 384 | $this->_out($this->DrawColor); 385 | } 386 | 387 | function SetFillColor($r, $g=null, $b=null) 388 | { 389 | // Set color for all filling operations 390 | if(($r==0 && $g==0 && $b==0) || $g===null) 391 | $this->FillColor = sprintf('%.3F g',$r/255); 392 | else 393 | $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); 394 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); 395 | if($this->page>0) 396 | $this->_out($this->FillColor); 397 | } 398 | 399 | function SetTextColor($r, $g=null, $b=null) 400 | { 401 | // Set color for text 402 | if(($r==0 && $g==0 && $b==0) || $g===null) 403 | $this->TextColor = sprintf('%.3F g',$r/255); 404 | else 405 | $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); 406 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); 407 | } 408 | 409 | function GetStringWidth($s) 410 | { 411 | // Get width of a string in the current font 412 | $s = (string)$s; 413 | $cw = &$this->CurrentFont['cw']; 414 | $w = 0; 415 | $l = strlen($s); 416 | for($i=0;$i<$l;$i++) 417 | $w += $cw[$s[$i]]; 418 | return $w*$this->FontSize/1000; 419 | } 420 | 421 | function SetLineWidth($width) 422 | { 423 | // Set line width 424 | $this->LineWidth = $width; 425 | if($this->page>0) 426 | $this->_out(sprintf('%.2F w',$width*$this->k)); 427 | } 428 | 429 | function Line($x1, $y1, $x2, $y2) 430 | { 431 | // Draw a line 432 | $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); 433 | } 434 | 435 | function Rect($x, $y, $w, $h, $style='') 436 | { 437 | // Draw a rectangle 438 | if($style=='F') 439 | $op = 'f'; 440 | elseif($style=='FD' || $style=='DF') 441 | $op = 'B'; 442 | else 443 | $op = 'S'; 444 | $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); 445 | } 446 | 447 | function AddFont($family, $style='', $file='') 448 | { 449 | // Add a TrueType, OpenType or Type1 font 450 | $family = strtolower($family); 451 | if($file=='') 452 | $file = str_replace(' ','',$family).strtolower($style).'.php'; 453 | $style = strtoupper($style); 454 | if($style=='IB') 455 | $style = 'BI'; 456 | $fontkey = $family.$style; 457 | if(isset($this->fonts[$fontkey])) 458 | return; 459 | $info = $this->_loadfont($file); 460 | $info['i'] = count($this->fonts)+1; 461 | if(!empty($info['file'])) 462 | { 463 | // Embedded font 464 | if($info['type']=='TrueType') 465 | $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); 466 | else 467 | $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); 468 | } 469 | $this->fonts[$fontkey] = $info; 470 | } 471 | 472 | function SetFont($family, $style='', $size=0) 473 | { 474 | // Select a font; size given in points 475 | if($family=='') 476 | $family = $this->FontFamily; 477 | else 478 | $family = strtolower($family); 479 | $style = strtoupper($style); 480 | if(strpos($style,'U')!==false) 481 | { 482 | $this->underline = true; 483 | $style = str_replace('U','',$style); 484 | } 485 | else 486 | $this->underline = false; 487 | if($style=='IB') 488 | $style = 'BI'; 489 | if($size==0) 490 | $size = $this->FontSizePt; 491 | // Test if font is already selected 492 | if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) 493 | return; 494 | // Test if font is already loaded 495 | $fontkey = $family.$style; 496 | if(!isset($this->fonts[$fontkey])) 497 | { 498 | // Test if one of the core fonts 499 | if($family=='arial') 500 | $family = 'helvetica'; 501 | if(in_array($family,$this->CoreFonts)) 502 | { 503 | if($family=='symbol' || $family=='zapfdingbats') 504 | $style = ''; 505 | $fontkey = $family.$style; 506 | if(!isset($this->fonts[$fontkey])) 507 | $this->AddFont($family,$style); 508 | } 509 | else 510 | $this->Error('Undefined font: '.$family.' '.$style); 511 | } 512 | // Select it 513 | $this->FontFamily = $family; 514 | $this->FontStyle = $style; 515 | $this->FontSizePt = $size; 516 | $this->FontSize = $size/$this->k; 517 | $this->CurrentFont = &$this->fonts[$fontkey]; 518 | if($this->page>0) 519 | $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 520 | } 521 | 522 | function SetFontSize($size) 523 | { 524 | // Set font size in points 525 | if($this->FontSizePt==$size) 526 | return; 527 | $this->FontSizePt = $size; 528 | $this->FontSize = $size/$this->k; 529 | if($this->page>0) 530 | $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); 531 | } 532 | 533 | function AddLink() 534 | { 535 | // Create a new internal link 536 | $n = count($this->links)+1; 537 | $this->links[$n] = array(0, 0); 538 | return $n; 539 | } 540 | 541 | function SetLink($link, $y=0, $page=-1) 542 | { 543 | // Set destination of internal link 544 | if($y==-1) 545 | $y = $this->y; 546 | if($page==-1) 547 | $page = $this->page; 548 | $this->links[$link] = array($page, $y); 549 | } 550 | 551 | function Link($x, $y, $w, $h, $link) 552 | { 553 | // Put a link on the page 554 | $this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); 555 | } 556 | 557 | function Text($x, $y, $txt) 558 | { 559 | // Output a string 560 | if(!isset($this->CurrentFont)) 561 | $this->Error('No font has been set'); 562 | $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); 563 | if($this->underline && $txt!='') 564 | $s .= ' '.$this->_dounderline($x,$y,$txt); 565 | if($this->ColorFlag) 566 | $s = 'q '.$this->TextColor.' '.$s.' Q'; 567 | $this->_out($s); 568 | } 569 | 570 | function AcceptPageBreak() 571 | { 572 | // Accept automatic page break or not 573 | return $this->AutoPageBreak; 574 | } 575 | 576 | function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') 577 | { 578 | // Output a cell 579 | $k = $this->k; 580 | if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) 581 | { 582 | // Automatic page break 583 | $x = $this->x; 584 | $ws = $this->ws; 585 | if($ws>0) 586 | { 587 | $this->ws = 0; 588 | $this->_out('0 Tw'); 589 | } 590 | $this->AddPage($this->CurOrientation,$this->CurPageSize,$this->CurRotation); 591 | $this->x = $x; 592 | if($ws>0) 593 | { 594 | $this->ws = $ws; 595 | $this->_out(sprintf('%.3F Tw',$ws*$k)); 596 | } 597 | } 598 | if($w==0) 599 | $w = $this->w-$this->rMargin-$this->x; 600 | $s = ''; 601 | if($fill || $border==1) 602 | { 603 | if($fill) 604 | $op = ($border==1) ? 'B' : 'f'; 605 | else 606 | $op = 'S'; 607 | $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); 608 | } 609 | if(is_string($border)) 610 | { 611 | $x = $this->x; 612 | $y = $this->y; 613 | if(strpos($border,'L')!==false) 614 | $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); 615 | if(strpos($border,'T')!==false) 616 | $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); 617 | if(strpos($border,'R')!==false) 618 | $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 619 | if(strpos($border,'B')!==false) 620 | $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); 621 | } 622 | if($txt!=='') 623 | { 624 | if(!isset($this->CurrentFont)) 625 | $this->Error('No font has been set'); 626 | if($align=='R') 627 | $dx = $w-$this->cMargin-$this->GetStringWidth($txt); 628 | elseif($align=='C') 629 | $dx = ($w-$this->GetStringWidth($txt))/2; 630 | else 631 | $dx = $this->cMargin; 632 | if($this->ColorFlag) 633 | $s .= 'q '.$this->TextColor.' '; 634 | $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$this->_escape($txt)); 635 | if($this->underline) 636 | $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); 637 | if($this->ColorFlag) 638 | $s .= ' Q'; 639 | if($link) 640 | $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); 641 | } 642 | if($s) 643 | $this->_out($s); 644 | $this->lasth = $h; 645 | if($ln>0) 646 | { 647 | // Go to next line 648 | $this->y += $h; 649 | if($ln==1) 650 | $this->x = $this->lMargin; 651 | } 652 | else 653 | $this->x += $w; 654 | } 655 | 656 | function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) 657 | { 658 | // Output text with automatic or explicit line breaks 659 | if(!isset($this->CurrentFont)) 660 | $this->Error('No font has been set'); 661 | $cw = &$this->CurrentFont['cw']; 662 | if($w==0) 663 | $w = $this->w-$this->rMargin-$this->x; 664 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; 665 | $s = str_replace("\r",'',$txt); 666 | $nb = strlen($s); 667 | if($nb>0 && $s[$nb-1]=="\n") 668 | $nb--; 669 | $b = 0; 670 | if($border) 671 | { 672 | if($border==1) 673 | { 674 | $border = 'LTRB'; 675 | $b = 'LRT'; 676 | $b2 = 'LR'; 677 | } 678 | else 679 | { 680 | $b2 = ''; 681 | if(strpos($border,'L')!==false) 682 | $b2 .= 'L'; 683 | if(strpos($border,'R')!==false) 684 | $b2 .= 'R'; 685 | $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; 686 | } 687 | } 688 | $sep = -1; 689 | $i = 0; 690 | $j = 0; 691 | $l = 0; 692 | $ns = 0; 693 | $nl = 1; 694 | while($i<$nb) 695 | { 696 | // Get next character 697 | $c = $s[$i]; 698 | if($c=="\n") 699 | { 700 | // Explicit line break 701 | if($this->ws>0) 702 | { 703 | $this->ws = 0; 704 | $this->_out('0 Tw'); 705 | } 706 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); 707 | $i++; 708 | $sep = -1; 709 | $j = $i; 710 | $l = 0; 711 | $ns = 0; 712 | $nl++; 713 | if($border && $nl==2) 714 | $b = $b2; 715 | continue; 716 | } 717 | if($c==' ') 718 | { 719 | $sep = $i; 720 | $ls = $l; 721 | $ns++; 722 | } 723 | $l += $cw[$c]; 724 | if($l>$wmax) 725 | { 726 | // Automatic line break 727 | if($sep==-1) 728 | { 729 | if($i==$j) 730 | $i++; 731 | if($this->ws>0) 732 | { 733 | $this->ws = 0; 734 | $this->_out('0 Tw'); 735 | } 736 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); 737 | } 738 | else 739 | { 740 | if($align=='J') 741 | { 742 | $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; 743 | $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); 744 | } 745 | $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); 746 | $i = $sep+1; 747 | } 748 | $sep = -1; 749 | $j = $i; 750 | $l = 0; 751 | $ns = 0; 752 | $nl++; 753 | if($border && $nl==2) 754 | $b = $b2; 755 | } 756 | else 757 | $i++; 758 | } 759 | // Last chunk 760 | if($this->ws>0) 761 | { 762 | $this->ws = 0; 763 | $this->_out('0 Tw'); 764 | } 765 | if($border && strpos($border,'B')!==false) 766 | $b .= 'B'; 767 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); 768 | $this->x = $this->lMargin; 769 | } 770 | 771 | function Write($h, $txt, $link='') 772 | { 773 | // Output text in flowing mode 774 | if(!isset($this->CurrentFont)) 775 | $this->Error('No font has been set'); 776 | $cw = &$this->CurrentFont['cw']; 777 | $w = $this->w-$this->rMargin-$this->x; 778 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; 779 | $s = str_replace("\r",'',$txt); 780 | $nb = strlen($s); 781 | $sep = -1; 782 | $i = 0; 783 | $j = 0; 784 | $l = 0; 785 | $nl = 1; 786 | while($i<$nb) 787 | { 788 | // Get next character 789 | $c = $s[$i]; 790 | if($c=="\n") 791 | { 792 | // Explicit line break 793 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); 794 | $i++; 795 | $sep = -1; 796 | $j = $i; 797 | $l = 0; 798 | if($nl==1) 799 | { 800 | $this->x = $this->lMargin; 801 | $w = $this->w-$this->rMargin-$this->x; 802 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; 803 | } 804 | $nl++; 805 | continue; 806 | } 807 | if($c==' ') 808 | $sep = $i; 809 | $l += $cw[$c]; 810 | if($l>$wmax) 811 | { 812 | // Automatic line break 813 | if($sep==-1) 814 | { 815 | if($this->x>$this->lMargin) 816 | { 817 | // Move to next line 818 | $this->x = $this->lMargin; 819 | $this->y += $h; 820 | $w = $this->w-$this->rMargin-$this->x; 821 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; 822 | $i++; 823 | $nl++; 824 | continue; 825 | } 826 | if($i==$j) 827 | $i++; 828 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); 829 | } 830 | else 831 | { 832 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); 833 | $i = $sep+1; 834 | } 835 | $sep = -1; 836 | $j = $i; 837 | $l = 0; 838 | if($nl==1) 839 | { 840 | $this->x = $this->lMargin; 841 | $w = $this->w-$this->rMargin-$this->x; 842 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; 843 | } 844 | $nl++; 845 | } 846 | else 847 | $i++; 848 | } 849 | // Last chunk 850 | if($i!=$j) 851 | $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); 852 | } 853 | 854 | function Ln($h=null) 855 | { 856 | // Line feed; default value is the last cell height 857 | $this->x = $this->lMargin; 858 | if($h===null) 859 | $this->y += $this->lasth; 860 | else 861 | $this->y += $h; 862 | } 863 | 864 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') 865 | { 866 | // Put an image on the page 867 | if($file=='') 868 | $this->Error('Image file name is empty'); 869 | if(!isset($this->images[$file])) 870 | { 871 | // First use of this image, get info 872 | if($type=='') 873 | { 874 | $pos = strrpos($file,'.'); 875 | if(!$pos) 876 | $this->Error('Image file has no extension and no type was specified: '.$file); 877 | $type = substr($file,$pos+1); 878 | } 879 | $type = strtolower($type); 880 | if($type=='jpeg') 881 | $type = 'jpg'; 882 | $mtd = '_parse'.$type; 883 | if(!method_exists($this,$mtd)) 884 | $this->Error('Unsupported image type: '.$type); 885 | $info = $this->$mtd($file); 886 | $info['i'] = count($this->images)+1; 887 | $this->images[$file] = $info; 888 | } 889 | else 890 | $info = $this->images[$file]; 891 | 892 | // Automatic width and height calculation if needed 893 | if($w==0 && $h==0) 894 | { 895 | // Put image at 96 dpi 896 | $w = -96; 897 | $h = -96; 898 | } 899 | if($w<0) 900 | $w = -$info['w']*72/$w/$this->k; 901 | if($h<0) 902 | $h = -$info['h']*72/$h/$this->k; 903 | if($w==0) 904 | $w = $h*$info['w']/$info['h']; 905 | if($h==0) 906 | $h = $w*$info['h']/$info['w']; 907 | 908 | // Flowing mode 909 | if($y===null) 910 | { 911 | if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) 912 | { 913 | // Automatic page break 914 | $x2 = $this->x; 915 | $this->AddPage($this->CurOrientation,$this->CurPageSize,$this->CurRotation); 916 | $this->x = $x2; 917 | } 918 | $y = $this->y; 919 | $this->y += $h; 920 | } 921 | 922 | if($x===null) 923 | $x = $this->x; 924 | $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); 925 | if($link) 926 | $this->Link($x,$y,$w,$h,$link); 927 | } 928 | 929 | function GetPageWidth() 930 | { 931 | // Get current page width 932 | return $this->w; 933 | } 934 | 935 | function GetPageHeight() 936 | { 937 | // Get current page height 938 | return $this->h; 939 | } 940 | 941 | function GetX() 942 | { 943 | // Get x position 944 | return $this->x; 945 | } 946 | 947 | function SetX($x) 948 | { 949 | // Set x position 950 | if($x>=0) 951 | $this->x = $x; 952 | else 953 | $this->x = $this->w+$x; 954 | } 955 | 956 | function GetY() 957 | { 958 | // Get y position 959 | return $this->y; 960 | } 961 | 962 | function SetY($y, $resetX=true) 963 | { 964 | // Set y position and optionally reset x 965 | if($y>=0) 966 | $this->y = $y; 967 | else 968 | $this->y = $this->h+$y; 969 | if($resetX) 970 | $this->x = $this->lMargin; 971 | } 972 | 973 | function SetXY($x, $y) 974 | { 975 | // Set x and y positions 976 | $this->SetX($x); 977 | $this->SetY($y,false); 978 | } 979 | 980 | function Output($dest='', $name='', $isUTF8=false) 981 | { 982 | // Output PDF to some destination 983 | $this->Close(); 984 | if(strlen($name)==1 && strlen($dest)!=1) 985 | { 986 | // Fix parameter order 987 | $tmp = $dest; 988 | $dest = $name; 989 | $name = $tmp; 990 | } 991 | if($dest=='') 992 | $dest = 'I'; 993 | if($name=='') 994 | $name = 'doc.pdf'; 995 | switch(strtoupper($dest)) 996 | { 997 | case 'I': 998 | // Send to standard output 999 | $this->_checkoutput(); 1000 | if(PHP_SAPI!='cli') 1001 | { 1002 | // We send to a browser 1003 | header('Content-Type: application/pdf'); 1004 | header('Content-Disposition: inline; '.$this->_httpencode('filename',$name,$isUTF8)); 1005 | header('Cache-Control: private, max-age=0, must-revalidate'); 1006 | header('Pragma: public'); 1007 | } 1008 | echo $this->buffer; 1009 | break; 1010 | case 'D': 1011 | // Download file 1012 | $this->_checkoutput(); 1013 | header('Content-Type: application/x-download'); 1014 | header('Content-Disposition: attachment; '.$this->_httpencode('filename',$name,$isUTF8)); 1015 | header('Cache-Control: private, max-age=0, must-revalidate'); 1016 | header('Pragma: public'); 1017 | echo $this->buffer; 1018 | break; 1019 | case 'F': 1020 | // Save to local file 1021 | if(!file_put_contents($name,$this->buffer)) 1022 | $this->Error('Unable to create output file: '.$name); 1023 | break; 1024 | case 'S': 1025 | // Return as a string 1026 | return $this->buffer; 1027 | default: 1028 | $this->Error('Incorrect output destination: '.$dest); 1029 | } 1030 | return ''; 1031 | } 1032 | 1033 | /******************************************************************************* 1034 | * Protected methods * 1035 | *******************************************************************************/ 1036 | 1037 | protected function _dochecks() 1038 | { 1039 | // Check mbstring overloading 1040 | if(ini_get('mbstring.func_overload') & 2) 1041 | $this->Error('mbstring overloading must be disabled'); 1042 | // Ensure runtime magic quotes are disabled 1043 | if(get_magic_quotes_runtime()) 1044 | @set_magic_quotes_runtime(0); 1045 | } 1046 | 1047 | protected function _checkoutput() 1048 | { 1049 | if(PHP_SAPI!='cli') 1050 | { 1051 | if(headers_sent($file,$line)) 1052 | $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); 1053 | } 1054 | if(ob_get_length()) 1055 | { 1056 | // The output buffer is not empty 1057 | if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents())) 1058 | { 1059 | // It contains only a UTF-8 BOM and/or whitespace, let's clean it 1060 | ob_clean(); 1061 | } 1062 | else 1063 | $this->Error("Some data has already been output, can't send PDF file"); 1064 | } 1065 | } 1066 | 1067 | protected function _getpagesize($size) 1068 | { 1069 | if(is_string($size)) 1070 | { 1071 | $size = strtolower($size); 1072 | if(!isset($this->StdPageSizes[$size])) 1073 | $this->Error('Unknown page size: '.$size); 1074 | $a = $this->StdPageSizes[$size]; 1075 | return array($a[0]/$this->k, $a[1]/$this->k); 1076 | } 1077 | else 1078 | { 1079 | if($size[0]>$size[1]) 1080 | return array($size[1], $size[0]); 1081 | else 1082 | return $size; 1083 | } 1084 | } 1085 | 1086 | protected function _beginpage($orientation, $size, $rotation) 1087 | { 1088 | $this->page++; 1089 | $this->pages[$this->page] = ''; 1090 | $this->state = 2; 1091 | $this->x = $this->lMargin; 1092 | $this->y = $this->tMargin; 1093 | $this->FontFamily = ''; 1094 | // Check page size and orientation 1095 | if($orientation=='') 1096 | $orientation = $this->DefOrientation; 1097 | else 1098 | $orientation = strtoupper($orientation[0]); 1099 | if($size=='') 1100 | $size = $this->DefPageSize; 1101 | else 1102 | $size = $this->_getpagesize($size); 1103 | if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) 1104 | { 1105 | // New size or orientation 1106 | if($orientation=='P') 1107 | { 1108 | $this->w = $size[0]; 1109 | $this->h = $size[1]; 1110 | } 1111 | else 1112 | { 1113 | $this->w = $size[1]; 1114 | $this->h = $size[0]; 1115 | } 1116 | $this->wPt = $this->w*$this->k; 1117 | $this->hPt = $this->h*$this->k; 1118 | $this->PageBreakTrigger = $this->h-$this->bMargin; 1119 | $this->CurOrientation = $orientation; 1120 | $this->CurPageSize = $size; 1121 | } 1122 | if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) 1123 | $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); 1124 | if($rotation!=0) 1125 | { 1126 | if($rotation%90!=0) 1127 | $this->Error('Incorrect rotation value: '.$rotation); 1128 | $this->CurRotation = $rotation; 1129 | $this->PageInfo[$this->page]['rotation'] = $rotation; 1130 | } 1131 | } 1132 | 1133 | protected function _endpage() 1134 | { 1135 | $this->state = 1; 1136 | } 1137 | 1138 | protected function _loadfont($font) 1139 | { 1140 | // Load a font definition file from the font directory 1141 | if(strpos($font,'/')!==false || strpos($font,"\\")!==false) 1142 | $this->Error('Incorrect font definition file name: '.$font); 1143 | include($this->fontpath.$font); 1144 | if(!isset($name)) 1145 | $this->Error('Could not include font definition file'); 1146 | if(isset($enc)) 1147 | $enc = strtolower($enc); 1148 | if(!isset($subsetted)) 1149 | $subsetted = false; 1150 | return get_defined_vars(); 1151 | } 1152 | 1153 | protected function _isascii($s) 1154 | { 1155 | // Test if string is ASCII 1156 | $nb = strlen($s); 1157 | for($i=0;$i<$nb;$i++) 1158 | { 1159 | if(ord($s[$i])>127) 1160 | return false; 1161 | } 1162 | return true; 1163 | } 1164 | 1165 | protected function _httpencode($param, $value, $isUTF8) 1166 | { 1167 | // Encode HTTP header field parameter 1168 | if($this->_isascii($value)) 1169 | return $param.'="'.$value.'"'; 1170 | if(!$isUTF8) 1171 | $value = utf8_encode($value); 1172 | if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) 1173 | return $param.'="'.rawurlencode($value).'"'; 1174 | else 1175 | return $param."*=UTF-8''".rawurlencode($value); 1176 | } 1177 | 1178 | protected function _UTF8toUTF16($s) 1179 | { 1180 | // Convert UTF-8 to UTF-16BE with BOM 1181 | $res = "\xFE\xFF"; 1182 | $nb = strlen($s); 1183 | $i = 0; 1184 | while($i<$nb) 1185 | { 1186 | $c1 = ord($s[$i++]); 1187 | if($c1>=224) 1188 | { 1189 | // 3-byte character 1190 | $c2 = ord($s[$i++]); 1191 | $c3 = ord($s[$i++]); 1192 | $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); 1193 | $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); 1194 | } 1195 | elseif($c1>=192) 1196 | { 1197 | // 2-byte character 1198 | $c2 = ord($s[$i++]); 1199 | $res .= chr(($c1 & 0x1C)>>2); 1200 | $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); 1201 | } 1202 | else 1203 | { 1204 | // Single-byte character 1205 | $res .= "\0".chr($c1); 1206 | } 1207 | } 1208 | return $res; 1209 | } 1210 | 1211 | protected function _escape($s) 1212 | { 1213 | // Escape special characters 1214 | if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) 1215 | return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); 1216 | else 1217 | return $s; 1218 | } 1219 | 1220 | protected function _textstring($s) 1221 | { 1222 | // Format a text string 1223 | if(!$this->_isascii($s)) 1224 | $s = $this->_UTF8toUTF16($s); 1225 | return '('.$this->_escape($s).')'; 1226 | } 1227 | 1228 | protected function _dounderline($x, $y, $txt) 1229 | { 1230 | // Underline text 1231 | $up = $this->CurrentFont['up']; 1232 | $ut = $this->CurrentFont['ut']; 1233 | $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); 1234 | return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); 1235 | } 1236 | 1237 | protected function _parsejpg($file) 1238 | { 1239 | // Extract info from a JPEG file 1240 | $a = getimagesize($file); 1241 | if(!$a) 1242 | $this->Error('Missing or incorrect image file: '.$file); 1243 | if($a[2]!=2) 1244 | $this->Error('Not a JPEG file: '.$file); 1245 | if(!isset($a['channels']) || $a['channels']==3) 1246 | $colspace = 'DeviceRGB'; 1247 | elseif($a['channels']==4) 1248 | $colspace = 'DeviceCMYK'; 1249 | else 1250 | $colspace = 'DeviceGray'; 1251 | $bpc = isset($a['bits']) ? $a['bits'] : 8; 1252 | $data = file_get_contents($file); 1253 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); 1254 | } 1255 | 1256 | protected function _parsepng($file) 1257 | { 1258 | // Extract info from a PNG file 1259 | $f = fopen($file,'rb'); 1260 | if(!$f) 1261 | $this->Error('Can\'t open image file: '.$file); 1262 | $info = $this->_parsepngstream($f,$file); 1263 | fclose($f); 1264 | return $info; 1265 | } 1266 | 1267 | protected function _parsepngstream($f, $file) 1268 | { 1269 | // Check signature 1270 | if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) 1271 | $this->Error('Not a PNG file: '.$file); 1272 | 1273 | // Read header chunk 1274 | $this->_readstream($f,4); 1275 | if($this->_readstream($f,4)!='IHDR') 1276 | $this->Error('Incorrect PNG file: '.$file); 1277 | $w = $this->_readint($f); 1278 | $h = $this->_readint($f); 1279 | $bpc = ord($this->_readstream($f,1)); 1280 | if($bpc>8) 1281 | $this->Error('16-bit depth not supported: '.$file); 1282 | $ct = ord($this->_readstream($f,1)); 1283 | if($ct==0 || $ct==4) 1284 | $colspace = 'DeviceGray'; 1285 | elseif($ct==2 || $ct==6) 1286 | $colspace = 'DeviceRGB'; 1287 | elseif($ct==3) 1288 | $colspace = 'Indexed'; 1289 | else 1290 | $this->Error('Unknown color type: '.$file); 1291 | if(ord($this->_readstream($f,1))!=0) 1292 | $this->Error('Unknown compression method: '.$file); 1293 | if(ord($this->_readstream($f,1))!=0) 1294 | $this->Error('Unknown filter method: '.$file); 1295 | if(ord($this->_readstream($f,1))!=0) 1296 | $this->Error('Interlacing not supported: '.$file); 1297 | $this->_readstream($f,4); 1298 | $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; 1299 | 1300 | // Scan chunks looking for palette, transparency and image data 1301 | $pal = ''; 1302 | $trns = ''; 1303 | $data = ''; 1304 | do 1305 | { 1306 | $n = $this->_readint($f); 1307 | $type = $this->_readstream($f,4); 1308 | if($type=='PLTE') 1309 | { 1310 | // Read palette 1311 | $pal = $this->_readstream($f,$n); 1312 | $this->_readstream($f,4); 1313 | } 1314 | elseif($type=='tRNS') 1315 | { 1316 | // Read transparency info 1317 | $t = $this->_readstream($f,$n); 1318 | if($ct==0) 1319 | $trns = array(ord(substr($t,1,1))); 1320 | elseif($ct==2) 1321 | $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); 1322 | else 1323 | { 1324 | $pos = strpos($t,chr(0)); 1325 | if($pos!==false) 1326 | $trns = array($pos); 1327 | } 1328 | $this->_readstream($f,4); 1329 | } 1330 | elseif($type=='IDAT') 1331 | { 1332 | // Read image data block 1333 | $data .= $this->_readstream($f,$n); 1334 | $this->_readstream($f,4); 1335 | } 1336 | elseif($type=='IEND') 1337 | break; 1338 | else 1339 | $this->_readstream($f,$n+4); 1340 | } 1341 | while($n); 1342 | 1343 | if($colspace=='Indexed' && empty($pal)) 1344 | $this->Error('Missing palette in '.$file); 1345 | $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); 1346 | if($ct>=4) 1347 | { 1348 | // Extract alpha channel 1349 | if(!function_exists('gzuncompress')) 1350 | $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); 1351 | $data = gzuncompress($data); 1352 | $color = ''; 1353 | $alpha = ''; 1354 | if($ct==4) 1355 | { 1356 | // Gray image 1357 | $len = 2*$w; 1358 | for($i=0;$i<$h;$i++) 1359 | { 1360 | $pos = (1+$len)*$i; 1361 | $color .= $data[$pos]; 1362 | $alpha .= $data[$pos]; 1363 | $line = substr($data,$pos+1,$len); 1364 | $color .= preg_replace('/(.)./s','$1',$line); 1365 | $alpha .= preg_replace('/.(.)/s','$1',$line); 1366 | } 1367 | } 1368 | else 1369 | { 1370 | // RGB image 1371 | $len = 4*$w; 1372 | for($i=0;$i<$h;$i++) 1373 | { 1374 | $pos = (1+$len)*$i; 1375 | $color .= $data[$pos]; 1376 | $alpha .= $data[$pos]; 1377 | $line = substr($data,$pos+1,$len); 1378 | $color .= preg_replace('/(.{3})./s','$1',$line); 1379 | $alpha .= preg_replace('/.{3}(.)/s','$1',$line); 1380 | } 1381 | } 1382 | unset($data); 1383 | $data = gzcompress($color); 1384 | $info['smask'] = gzcompress($alpha); 1385 | $this->WithAlpha = true; 1386 | if($this->PDFVersion<'1.4') 1387 | $this->PDFVersion = '1.4'; 1388 | } 1389 | $info['data'] = $data; 1390 | return $info; 1391 | } 1392 | 1393 | protected function _readstream($f, $n) 1394 | { 1395 | // Read n bytes from stream 1396 | $res = ''; 1397 | while($n>0 && !feof($f)) 1398 | { 1399 | $s = fread($f,$n); 1400 | if($s===false) 1401 | $this->Error('Error while reading stream'); 1402 | $n -= strlen($s); 1403 | $res .= $s; 1404 | } 1405 | if($n>0) 1406 | $this->Error('Unexpected end of stream'); 1407 | return $res; 1408 | } 1409 | 1410 | protected function _readint($f) 1411 | { 1412 | // Read a 4-byte integer from stream 1413 | $a = unpack('Ni',$this->_readstream($f,4)); 1414 | return $a['i']; 1415 | } 1416 | 1417 | protected function _parsegif($file) 1418 | { 1419 | // Extract info from a GIF file (via PNG conversion) 1420 | if(!function_exists('imagepng')) 1421 | $this->Error('GD extension is required for GIF support'); 1422 | if(!function_exists('imagecreatefromgif')) 1423 | $this->Error('GD has no GIF read support'); 1424 | $im = imagecreatefromgif($file); 1425 | if(!$im) 1426 | $this->Error('Missing or incorrect image file: '.$file); 1427 | imageinterlace($im,0); 1428 | ob_start(); 1429 | imagepng($im); 1430 | $data = ob_get_clean(); 1431 | imagedestroy($im); 1432 | $f = fopen('php://temp','rb+'); 1433 | if(!$f) 1434 | $this->Error('Unable to create memory stream'); 1435 | fwrite($f,$data); 1436 | rewind($f); 1437 | $info = $this->_parsepngstream($f,$file); 1438 | fclose($f); 1439 | return $info; 1440 | } 1441 | 1442 | protected function _out($s) 1443 | { 1444 | // Add a line to the document 1445 | if($this->state==2) 1446 | $this->pages[$this->page] .= $s."\n"; 1447 | elseif($this->state==1) 1448 | $this->_put($s); 1449 | elseif($this->state==0) 1450 | $this->Error('No page has been added yet'); 1451 | elseif($this->state==3) 1452 | $this->Error('The document is closed'); 1453 | } 1454 | 1455 | protected function _put($s) 1456 | { 1457 | $this->buffer .= $s."\n"; 1458 | } 1459 | 1460 | protected function _getoffset() 1461 | { 1462 | return strlen($this->buffer); 1463 | } 1464 | 1465 | protected function _newobj($n=null) 1466 | { 1467 | // Begin a new object 1468 | if($n===null) 1469 | $n = ++$this->n; 1470 | $this->offsets[$n] = $this->_getoffset(); 1471 | $this->_put($n.' 0 obj'); 1472 | } 1473 | 1474 | protected function _putstream($data) 1475 | { 1476 | $this->_put('stream'); 1477 | $this->_put($data); 1478 | $this->_put('endstream'); 1479 | } 1480 | 1481 | protected function _putstreamobject($data) 1482 | { 1483 | if($this->compress) 1484 | { 1485 | $entries = '/Filter /FlateDecode '; 1486 | $data = gzcompress($data); 1487 | } 1488 | else 1489 | $entries = ''; 1490 | $entries .= '/Length '.strlen($data); 1491 | $this->_newobj(); 1492 | $this->_put('<<'.$entries.'>>'); 1493 | $this->_putstream($data); 1494 | $this->_put('endobj'); 1495 | } 1496 | 1497 | protected function _putpage($n) 1498 | { 1499 | $this->_newobj(); 1500 | $this->_put('<_put('/Parent 1 0 R'); 1502 | if(isset($this->PageInfo[$n]['size'])) 1503 | $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); 1504 | if(isset($this->PageInfo[$n]['rotation'])) 1505 | $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); 1506 | $this->_put('/Resources 2 0 R'); 1507 | if(isset($this->PageLinks[$n])) 1508 | { 1509 | // Links 1510 | $annots = '/Annots ['; 1511 | foreach($this->PageLinks[$n] as $pl) 1512 | { 1513 | $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); 1514 | $annots .= '<_textstring($pl[4]).'>>>>'; 1517 | else 1518 | { 1519 | $l = $this->links[$pl[4]]; 1520 | if(isset($this->PageInfo[$l[0]]['size'])) 1521 | $h = $this->PageInfo[$l[0]]['size'][1]; 1522 | else 1523 | $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; 1524 | $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); 1525 | } 1526 | } 1527 | $this->_put($annots.']'); 1528 | } 1529 | if($this->WithAlpha) 1530 | $this->_put('/Group <>'); 1531 | $this->_put('/Contents '.($this->n+1).' 0 R>>'); 1532 | $this->_put('endobj'); 1533 | // Page content 1534 | if(!empty($this->AliasNbPages)) 1535 | $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); 1536 | $this->_putstreamobject($this->pages[$n]); 1537 | } 1538 | 1539 | protected function _putpages() 1540 | { 1541 | $nb = $this->page; 1542 | for($n=1;$n<=$nb;$n++) 1543 | $this->PageInfo[$n]['n'] = $this->n+1+2*($n-1); 1544 | for($n=1;$n<=$nb;$n++) 1545 | $this->_putpage($n); 1546 | // Pages root 1547 | $this->_newobj(1); 1548 | $this->_put('<PageInfo[$n]['n'].' 0 R '; 1552 | $this->_put($kids.']'); 1553 | $this->_put('/Count '.$nb); 1554 | if($this->DefOrientation=='P') 1555 | { 1556 | $w = $this->DefPageSize[0]; 1557 | $h = $this->DefPageSize[1]; 1558 | } 1559 | else 1560 | { 1561 | $w = $this->DefPageSize[1]; 1562 | $h = $this->DefPageSize[0]; 1563 | } 1564 | $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$w*$this->k,$h*$this->k)); 1565 | $this->_put('>>'); 1566 | $this->_put('endobj'); 1567 | } 1568 | 1569 | protected function _putfonts() 1570 | { 1571 | foreach($this->FontFiles as $file=>$info) 1572 | { 1573 | // Font file embedding 1574 | $this->_newobj(); 1575 | $this->FontFiles[$file]['n'] = $this->n; 1576 | $font = file_get_contents($this->fontpath.$file,true); 1577 | if(!$font) 1578 | $this->Error('Font file not found: '.$file); 1579 | $compressed = (substr($file,-2)=='.z'); 1580 | if(!$compressed && isset($info['length2'])) 1581 | $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); 1582 | $this->_put('<_put('/Filter /FlateDecode'); 1585 | $this->_put('/Length1 '.$info['length1']); 1586 | if(isset($info['length2'])) 1587 | $this->_put('/Length2 '.$info['length2'].' /Length3 0'); 1588 | $this->_put('>>'); 1589 | $this->_putstream($font); 1590 | $this->_put('endobj'); 1591 | } 1592 | foreach($this->fonts as $k=>$font) 1593 | { 1594 | // Encoding 1595 | if(isset($font['diff'])) 1596 | { 1597 | if(!isset($this->encodings[$font['enc']])) 1598 | { 1599 | $this->_newobj(); 1600 | $this->_put('<>'); 1601 | $this->_put('endobj'); 1602 | $this->encodings[$font['enc']] = $this->n; 1603 | } 1604 | } 1605 | // ToUnicode CMap 1606 | if(isset($font['uv'])) 1607 | { 1608 | if(isset($font['enc'])) 1609 | $cmapkey = $font['enc']; 1610 | else 1611 | $cmapkey = $font['name']; 1612 | if(!isset($this->cmaps[$cmapkey])) 1613 | { 1614 | $cmap = $this->_tounicodecmap($font['uv']); 1615 | $this->_putstreamobject($cmap); 1616 | $this->cmaps[$cmapkey] = $this->n; 1617 | } 1618 | } 1619 | // Font object 1620 | $this->fonts[$k]['n'] = $this->n+1; 1621 | $type = $font['type']; 1622 | $name = $font['name']; 1623 | if($font['subsetted']) 1624 | $name = 'AAAAAA+'.$name; 1625 | if($type=='Core') 1626 | { 1627 | // Core font 1628 | $this->_newobj(); 1629 | $this->_put('<_put('/BaseFont /'.$name); 1631 | $this->_put('/Subtype /Type1'); 1632 | if($name!='Symbol' && $name!='ZapfDingbats') 1633 | $this->_put('/Encoding /WinAnsiEncoding'); 1634 | if(isset($font['uv'])) 1635 | $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); 1636 | $this->_put('>>'); 1637 | $this->_put('endobj'); 1638 | } 1639 | elseif($type=='Type1' || $type=='TrueType') 1640 | { 1641 | // Additional Type1 or TrueType/OpenType font 1642 | $this->_newobj(); 1643 | $this->_put('<_put('/BaseFont /'.$name); 1645 | $this->_put('/Subtype /'.$type); 1646 | $this->_put('/FirstChar 32 /LastChar 255'); 1647 | $this->_put('/Widths '.($this->n+1).' 0 R'); 1648 | $this->_put('/FontDescriptor '.($this->n+2).' 0 R'); 1649 | if(isset($font['diff'])) 1650 | $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); 1651 | else 1652 | $this->_put('/Encoding /WinAnsiEncoding'); 1653 | if(isset($font['uv'])) 1654 | $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); 1655 | $this->_put('>>'); 1656 | $this->_put('endobj'); 1657 | // Widths 1658 | $this->_newobj(); 1659 | $cw = &$font['cw']; 1660 | $s = '['; 1661 | for($i=32;$i<=255;$i++) 1662 | $s .= $cw[chr($i)].' '; 1663 | $this->_put($s.']'); 1664 | $this->_put('endobj'); 1665 | // Descriptor 1666 | $this->_newobj(); 1667 | $s = '<$v) 1669 | $s .= ' /'.$k.' '.$v; 1670 | if(!empty($font['file'])) 1671 | $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; 1672 | $this->_put($s.'>>'); 1673 | $this->_put('endobj'); 1674 | } 1675 | else 1676 | { 1677 | // Allow for additional types 1678 | $mtd = '_put'.strtolower($type); 1679 | if(!method_exists($this,$mtd)) 1680 | $this->Error('Unsupported font type: '.$type); 1681 | $this->$mtd($font); 1682 | } 1683 | } 1684 | } 1685 | 1686 | protected function _tounicodecmap($uv) 1687 | { 1688 | $ranges = ''; 1689 | $nbr = 0; 1690 | $chars = ''; 1691 | $nbc = 0; 1692 | foreach($uv as $c=>$v) 1693 | { 1694 | if(is_array($v)) 1695 | { 1696 | $ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]); 1697 | $nbr++; 1698 | } 1699 | else 1700 | { 1701 | $chars .= sprintf("<%02X> <%04X>\n",$c,$v); 1702 | $nbc++; 1703 | } 1704 | } 1705 | $s = "/CIDInit /ProcSet findresource begin\n"; 1706 | $s .= "12 dict begin\n"; 1707 | $s .= "begincmap\n"; 1708 | $s .= "/CIDSystemInfo\n"; 1709 | $s .= "<0) 1719 | { 1720 | $s .= "$nbr beginbfrange\n"; 1721 | $s .= $ranges; 1722 | $s .= "endbfrange\n"; 1723 | } 1724 | if($nbc>0) 1725 | { 1726 | $s .= "$nbc beginbfchar\n"; 1727 | $s .= $chars; 1728 | $s .= "endbfchar\n"; 1729 | } 1730 | $s .= "endcmap\n"; 1731 | $s .= "CMapName currentdict /CMap defineresource pop\n"; 1732 | $s .= "end\n"; 1733 | $s .= "end"; 1734 | return $s; 1735 | } 1736 | 1737 | protected function _putimages() 1738 | { 1739 | foreach(array_keys($this->images) as $file) 1740 | { 1741 | $this->_putimage($this->images[$file]); 1742 | unset($this->images[$file]['data']); 1743 | unset($this->images[$file]['smask']); 1744 | } 1745 | } 1746 | 1747 | protected function _putimage(&$info) 1748 | { 1749 | $this->_newobj(); 1750 | $info['n'] = $this->n; 1751 | $this->_put('<_put('/Subtype /Image'); 1753 | $this->_put('/Width '.$info['w']); 1754 | $this->_put('/Height '.$info['h']); 1755 | if($info['cs']=='Indexed') 1756 | $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); 1757 | else 1758 | { 1759 | $this->_put('/ColorSpace /'.$info['cs']); 1760 | if($info['cs']=='DeviceCMYK') 1761 | $this->_put('/Decode [1 0 1 0 1 0 1 0]'); 1762 | } 1763 | $this->_put('/BitsPerComponent '.$info['bpc']); 1764 | if(isset($info['f'])) 1765 | $this->_put('/Filter /'.$info['f']); 1766 | if(isset($info['dp'])) 1767 | $this->_put('/DecodeParms <<'.$info['dp'].'>>'); 1768 | if(isset($info['trns']) && is_array($info['trns'])) 1769 | { 1770 | $trns = ''; 1771 | for($i=0;$i_put('/Mask ['.$trns.']'); 1774 | } 1775 | if(isset($info['smask'])) 1776 | $this->_put('/SMask '.($this->n+1).' 0 R'); 1777 | $this->_put('/Length '.strlen($info['data']).'>>'); 1778 | $this->_putstream($info['data']); 1779 | $this->_put('endobj'); 1780 | // Soft mask 1781 | if(isset($info['smask'])) 1782 | { 1783 | $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w']; 1784 | $smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']); 1785 | $this->_putimage($smask); 1786 | } 1787 | // Palette 1788 | if($info['cs']=='Indexed') 1789 | $this->_putstreamobject($info['pal']); 1790 | } 1791 | 1792 | protected function _putxobjectdict() 1793 | { 1794 | foreach($this->images as $image) 1795 | $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); 1796 | } 1797 | 1798 | protected function _putresourcedict() 1799 | { 1800 | $this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); 1801 | $this->_put('/Font <<'); 1802 | foreach($this->fonts as $font) 1803 | $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); 1804 | $this->_put('>>'); 1805 | $this->_put('/XObject <<'); 1806 | $this->_putxobjectdict(); 1807 | $this->_put('>>'); 1808 | } 1809 | 1810 | protected function _putresources() 1811 | { 1812 | $this->_putfonts(); 1813 | $this->_putimages(); 1814 | // Resource dictionary 1815 | $this->_newobj(2); 1816 | $this->_put('<<'); 1817 | $this->_putresourcedict(); 1818 | $this->_put('>>'); 1819 | $this->_put('endobj'); 1820 | } 1821 | 1822 | protected function _putinfo() 1823 | { 1824 | $this->metadata['Producer'] = 'FPDF '.FPDF_VERSION; 1825 | $this->metadata['CreationDate'] = 'D:'.@date('YmdHis'); 1826 | foreach($this->metadata as $key=>$value) 1827 | $this->_put('/'.$key.' '.$this->_textstring($value)); 1828 | } 1829 | 1830 | protected function _putcatalog() 1831 | { 1832 | $n = $this->PageInfo[1]['n']; 1833 | $this->_put('/Type /Catalog'); 1834 | $this->_put('/Pages 1 0 R'); 1835 | if($this->ZoomMode=='fullpage') 1836 | $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); 1837 | elseif($this->ZoomMode=='fullwidth') 1838 | $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); 1839 | elseif($this->ZoomMode=='real') 1840 | $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); 1841 | elseif(!is_string($this->ZoomMode)) 1842 | $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); 1843 | if($this->LayoutMode=='single') 1844 | $this->_put('/PageLayout /SinglePage'); 1845 | elseif($this->LayoutMode=='continuous') 1846 | $this->_put('/PageLayout /OneColumn'); 1847 | elseif($this->LayoutMode=='two') 1848 | $this->_put('/PageLayout /TwoColumnLeft'); 1849 | } 1850 | 1851 | protected function _putheader() 1852 | { 1853 | $this->_put('%PDF-'.$this->PDFVersion); 1854 | } 1855 | 1856 | protected function _puttrailer() 1857 | { 1858 | $this->_put('/Size '.($this->n+1)); 1859 | $this->_put('/Root '.$this->n.' 0 R'); 1860 | $this->_put('/Info '.($this->n-1).' 0 R'); 1861 | } 1862 | 1863 | protected function _enddoc() 1864 | { 1865 | $this->_putheader(); 1866 | $this->_putpages(); 1867 | $this->_putresources(); 1868 | // Info 1869 | $this->_newobj(); 1870 | $this->_put('<<'); 1871 | $this->_putinfo(); 1872 | $this->_put('>>'); 1873 | $this->_put('endobj'); 1874 | // Catalog 1875 | $this->_newobj(); 1876 | $this->_put('<<'); 1877 | $this->_putcatalog(); 1878 | $this->_put('>>'); 1879 | $this->_put('endobj'); 1880 | // Cross-ref 1881 | $offset = $this->_getoffset(); 1882 | $this->_put('xref'); 1883 | $this->_put('0 '.($this->n+1)); 1884 | $this->_put('0000000000 65535 f '); 1885 | for($i=1;$i<=$this->n;$i++) 1886 | $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); 1887 | // Trailer 1888 | $this->_put('trailer'); 1889 | $this->_put('<<'); 1890 | $this->_puttrailer(); 1891 | $this->_put('>>'); 1892 | $this->_put('startxref'); 1893 | $this->_put($offset); 1894 | $this->_put('%%EOF'); 1895 | $this->state = 3; 1896 | } 1897 | } 1898 | ?> 1899 | --------------------------------------------------------------------------------