@@ -4,7 +4,7 @@ |
||
| 4 | 4 | $up = -100; |
| 5 | 5 | $ut = 50; |
| 6 | 6 | for($i=0;$i<=255;$i++) |
| 7 | - $cw[chr($i)] = 600; |
|
| 7 | + $cw[chr($i)] = 600; |
|
| 8 | 8 | $enc = 'cp1252'; |
| 9 | 9 | $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)); |
| 10 | 10 | ?> |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | $name = 'Courier-Oblique'; |
| 4 | 4 | $up = -100; |
| 5 | 5 | $ut = 50; |
| 6 | -for($i=0;$i<=255;$i++) |
|
| 6 | +for ($i = 0; $i <= 255; $i++) |
|
| 7 | 7 | $cw[chr($i)] = 600; |
| 8 | 8 | $enc = 'cp1252'; |
| 9 | -$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)); |
|
| 9 | +$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)); |
|
| 10 | 10 | ?> |
@@ -3,8 +3,9 @@ |
||
| 3 | 3 | $name = 'Courier-Oblique'; |
| 4 | 4 | $up = -100; |
| 5 | 5 | $ut = 50; |
| 6 | -for($i=0;$i<=255;$i++) |
|
| 6 | +for($i=0;$i<=255;$i++) { |
|
| 7 | 7 | $cw[chr($i)] = 600; |
| 8 | +} |
|
| 8 | 9 | $enc = 'cp1252'; |
| 9 | 10 | $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)); |
| 10 | 11 | ?> |
@@ -5,18 +5,18 @@ |
||
| 5 | 5 | $up = -200; |
| 6 | 6 | $ut = 20; |
| 7 | 7 | $cw = array( |
| 8 | - chr(0)=>800,chr(1)=>800,chr(2)=>800,chr(3)=>800,chr(4)=>800,chr(5)=>800,chr(6)=>800,chr(7)=>800,chr(8)=>800,chr(9)=>800,chr(10)=>800,chr(11)=>800,chr(12)=>800,chr(13)=>800,chr(14)=>800,chr(15)=>800,chr(16)=>800,chr(17)=>800,chr(18)=>800,chr(19)=>800,chr(20)=>800,chr(21)=>800, |
|
| 9 | - chr(22)=>800,chr(23)=>800,chr(24)=>800,chr(25)=>800,chr(26)=>800,chr(27)=>800,chr(28)=>800,chr(29)=>800,chr(30)=>800,chr(31)=>800,' '=>282,'!'=>324,'"'=>405,'#'=>584,'$'=>632,'%'=>980,'&'=>776,'\''=>259,'('=>299,')'=>299,'*'=>377,'+'=>600, |
|
| 10 | - ','=>259,'-'=>432,'.'=>254,'/'=>597,'0'=>529,'1'=>298,'2'=>451,'3'=>359,'4'=>525,'5'=>423,'6'=>464,'7'=>417,'8'=>457,'9'=>479,':'=>275,';'=>282,'<'=>600,'='=>600,'>'=>600,'?'=>501,'@'=>800,'A'=>743, |
|
| 11 | - 'B'=>636,'C'=>598,'D'=>712,'E'=>608,'F'=>562,'G'=>680,'H'=>756,'I'=>308,'J'=>314,'K'=>676,'L'=>552,'M'=>1041,'N'=>817,'O'=>729,'P'=>569,'Q'=>698,'R'=>674,'S'=>618,'T'=>673,'U'=>805,'V'=>753,'W'=>1238, |
|
| 12 | - 'X'=>716,'Y'=>754,'Z'=>599,'['=>315,'\\'=>463,']'=>315,'^'=>600,'_'=>547,'`'=>278,'a'=>581,'b'=>564,'c'=>440,'d'=>571,'e'=>450,'f'=>347,'g'=>628,'h'=>611,'i'=>283,'j'=>283,'k'=>560,'l'=>252,'m'=>976, |
|
| 13 | - 'n'=>595,'o'=>508,'p'=>549,'q'=>540,'r'=>395,'s'=>441,'t'=>307,'u'=>614,'v'=>556,'w'=>915,'x'=>559,'y'=>597,'z'=>452,'{'=>315,'|'=>222,'}'=>315,'~'=>600,chr(127)=>800,chr(128)=>800,chr(129)=>800,chr(130)=>0,chr(131)=>0, |
|
| 14 | - chr(132)=>0,chr(133)=>780,chr(134)=>0,chr(135)=>0,chr(136)=>278,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>1064,chr(141)=>800,chr(142)=>0,chr(143)=>800,chr(144)=>800,chr(145)=>259,chr(146)=>259,chr(147)=>470,chr(148)=>470,chr(149)=>500,chr(150)=>300,chr(151)=>600,chr(152)=>278,chr(153)=>990, |
|
| 15 | - chr(154)=>0,chr(155)=>0,chr(156)=>790,chr(157)=>800,chr(158)=>800,chr(159)=>754,chr(160)=>282,chr(161)=>324,chr(162)=>450,chr(163)=>640,chr(164)=>518,chr(165)=>603,chr(166)=>0,chr(167)=>519,chr(168)=>254,chr(169)=>800,chr(170)=>349,chr(171)=>0,chr(172)=>0,chr(173)=>432,chr(174)=>800,chr(175)=>278, |
|
| 16 | - chr(176)=>0,chr(177)=>0,chr(178)=>0,chr(179)=>0,chr(180)=>278,chr(181)=>614,chr(182)=>0,chr(183)=>254,chr(184)=>278,chr(185)=>0,chr(186)=>305,chr(187)=>0,chr(188)=>0,chr(189)=>0,chr(190)=>0,chr(191)=>501,chr(192)=>743,chr(193)=>743,chr(194)=>743,chr(195)=>743,chr(196)=>743,chr(197)=>743, |
|
| 17 | - chr(198)=>1060,chr(199)=>598,chr(200)=>608,chr(201)=>608,chr(202)=>608,chr(203)=>608,chr(204)=>308,chr(205)=>308,chr(206)=>308,chr(207)=>308,chr(208)=>0,chr(209)=>817,chr(210)=>729,chr(211)=>729,chr(212)=>729,chr(213)=>729,chr(214)=>729,chr(215)=>0,chr(216)=>729,chr(217)=>805,chr(218)=>805,chr(219)=>805, |
|
| 18 | - chr(220)=>805,chr(221)=>0,chr(222)=>0,chr(223)=>688,chr(224)=>581,chr(225)=>581,chr(226)=>581,chr(227)=>581,chr(228)=>581,chr(229)=>581,chr(230)=>792,chr(231)=>440,chr(232)=>450,chr(233)=>450,chr(234)=>450,chr(235)=>450,chr(236)=>283,chr(237)=>283,chr(238)=>283,chr(239)=>283,chr(240)=>0,chr(241)=>595, |
|
| 19 | - chr(242)=>508,chr(243)=>508,chr(244)=>508,chr(245)=>508,chr(246)=>508,chr(247)=>0,chr(248)=>508,chr(249)=>614,chr(250)=>614,chr(251)=>614,chr(252)=>614,chr(253)=>0,chr(254)=>0,chr(255)=>597); |
|
| 8 | + chr(0)=>800,chr(1)=>800,chr(2)=>800,chr(3)=>800,chr(4)=>800,chr(5)=>800,chr(6)=>800,chr(7)=>800,chr(8)=>800,chr(9)=>800,chr(10)=>800,chr(11)=>800,chr(12)=>800,chr(13)=>800,chr(14)=>800,chr(15)=>800,chr(16)=>800,chr(17)=>800,chr(18)=>800,chr(19)=>800,chr(20)=>800,chr(21)=>800, |
|
| 9 | + chr(22)=>800,chr(23)=>800,chr(24)=>800,chr(25)=>800,chr(26)=>800,chr(27)=>800,chr(28)=>800,chr(29)=>800,chr(30)=>800,chr(31)=>800,' '=>282,'!'=>324,'"'=>405,'#'=>584,'$'=>632,'%'=>980,'&'=>776,'\''=>259,'('=>299,')'=>299,'*'=>377,'+'=>600, |
|
| 10 | + ','=>259,'-'=>432,'.'=>254,'/'=>597,'0'=>529,'1'=>298,'2'=>451,'3'=>359,'4'=>525,'5'=>423,'6'=>464,'7'=>417,'8'=>457,'9'=>479,':'=>275,';'=>282,'<'=>600,'='=>600,'>'=>600,'?'=>501,'@'=>800,'A'=>743, |
|
| 11 | + 'B'=>636,'C'=>598,'D'=>712,'E'=>608,'F'=>562,'G'=>680,'H'=>756,'I'=>308,'J'=>314,'K'=>676,'L'=>552,'M'=>1041,'N'=>817,'O'=>729,'P'=>569,'Q'=>698,'R'=>674,'S'=>618,'T'=>673,'U'=>805,'V'=>753,'W'=>1238, |
|
| 12 | + 'X'=>716,'Y'=>754,'Z'=>599,'['=>315,'\\'=>463,']'=>315,'^'=>600,'_'=>547,'`'=>278,'a'=>581,'b'=>564,'c'=>440,'d'=>571,'e'=>450,'f'=>347,'g'=>628,'h'=>611,'i'=>283,'j'=>283,'k'=>560,'l'=>252,'m'=>976, |
|
| 13 | + 'n'=>595,'o'=>508,'p'=>549,'q'=>540,'r'=>395,'s'=>441,'t'=>307,'u'=>614,'v'=>556,'w'=>915,'x'=>559,'y'=>597,'z'=>452,'{'=>315,'|'=>222,'}'=>315,'~'=>600,chr(127)=>800,chr(128)=>800,chr(129)=>800,chr(130)=>0,chr(131)=>0, |
|
| 14 | + chr(132)=>0,chr(133)=>780,chr(134)=>0,chr(135)=>0,chr(136)=>278,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>1064,chr(141)=>800,chr(142)=>0,chr(143)=>800,chr(144)=>800,chr(145)=>259,chr(146)=>259,chr(147)=>470,chr(148)=>470,chr(149)=>500,chr(150)=>300,chr(151)=>600,chr(152)=>278,chr(153)=>990, |
|
| 15 | + chr(154)=>0,chr(155)=>0,chr(156)=>790,chr(157)=>800,chr(158)=>800,chr(159)=>754,chr(160)=>282,chr(161)=>324,chr(162)=>450,chr(163)=>640,chr(164)=>518,chr(165)=>603,chr(166)=>0,chr(167)=>519,chr(168)=>254,chr(169)=>800,chr(170)=>349,chr(171)=>0,chr(172)=>0,chr(173)=>432,chr(174)=>800,chr(175)=>278, |
|
| 16 | + chr(176)=>0,chr(177)=>0,chr(178)=>0,chr(179)=>0,chr(180)=>278,chr(181)=>614,chr(182)=>0,chr(183)=>254,chr(184)=>278,chr(185)=>0,chr(186)=>305,chr(187)=>0,chr(188)=>0,chr(189)=>0,chr(190)=>0,chr(191)=>501,chr(192)=>743,chr(193)=>743,chr(194)=>743,chr(195)=>743,chr(196)=>743,chr(197)=>743, |
|
| 17 | + chr(198)=>1060,chr(199)=>598,chr(200)=>608,chr(201)=>608,chr(202)=>608,chr(203)=>608,chr(204)=>308,chr(205)=>308,chr(206)=>308,chr(207)=>308,chr(208)=>0,chr(209)=>817,chr(210)=>729,chr(211)=>729,chr(212)=>729,chr(213)=>729,chr(214)=>729,chr(215)=>0,chr(216)=>729,chr(217)=>805,chr(218)=>805,chr(219)=>805, |
|
| 18 | + chr(220)=>805,chr(221)=>0,chr(222)=>0,chr(223)=>688,chr(224)=>581,chr(225)=>581,chr(226)=>581,chr(227)=>581,chr(228)=>581,chr(229)=>581,chr(230)=>792,chr(231)=>440,chr(232)=>450,chr(233)=>450,chr(234)=>450,chr(235)=>450,chr(236)=>283,chr(237)=>283,chr(238)=>283,chr(239)=>283,chr(240)=>0,chr(241)=>595, |
|
| 19 | + chr(242)=>508,chr(243)=>508,chr(244)=>508,chr(245)=>508,chr(246)=>508,chr(247)=>0,chr(248)=>508,chr(249)=>614,chr(250)=>614,chr(251)=>614,chr(252)=>614,chr(253)=>0,chr(254)=>0,chr(255)=>597); |
|
| 20 | 20 | $enc = 'cp1252'; |
| 21 | 21 | $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)); |
| 22 | 22 | $file = 'calligra.z'; |
@@ -1,24 +1,24 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | $type = 'TrueType'; |
| 3 | 3 | $name = 'CalligrapherRegular'; |
| 4 | -$desc = array('Ascent'=>899,'Descent'=>-234,'CapHeight'=>899,'Flags'=>32,'FontBBox'=>'[-173 -234 1328 899]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>800); |
|
| 4 | +$desc = array('Ascent'=>899, 'Descent'=>-234, 'CapHeight'=>899, 'Flags'=>32, 'FontBBox'=>'[-173 -234 1328 899]', 'ItalicAngle'=>0, 'StemV'=>70, 'MissingWidth'=>800); |
|
| 5 | 5 | $up = -200; |
| 6 | 6 | $ut = 20; |
| 7 | 7 | $cw = array( |
| 8 | - chr(0)=>800,chr(1)=>800,chr(2)=>800,chr(3)=>800,chr(4)=>800,chr(5)=>800,chr(6)=>800,chr(7)=>800,chr(8)=>800,chr(9)=>800,chr(10)=>800,chr(11)=>800,chr(12)=>800,chr(13)=>800,chr(14)=>800,chr(15)=>800,chr(16)=>800,chr(17)=>800,chr(18)=>800,chr(19)=>800,chr(20)=>800,chr(21)=>800, |
|
| 9 | - chr(22)=>800,chr(23)=>800,chr(24)=>800,chr(25)=>800,chr(26)=>800,chr(27)=>800,chr(28)=>800,chr(29)=>800,chr(30)=>800,chr(31)=>800,' '=>282,'!'=>324,'"'=>405,'#'=>584,'$'=>632,'%'=>980,'&'=>776,'\''=>259,'('=>299,')'=>299,'*'=>377,'+'=>600, |
|
| 10 | - ','=>259,'-'=>432,'.'=>254,'/'=>597,'0'=>529,'1'=>298,'2'=>451,'3'=>359,'4'=>525,'5'=>423,'6'=>464,'7'=>417,'8'=>457,'9'=>479,':'=>275,';'=>282,'<'=>600,'='=>600,'>'=>600,'?'=>501,'@'=>800,'A'=>743, |
|
| 11 | - 'B'=>636,'C'=>598,'D'=>712,'E'=>608,'F'=>562,'G'=>680,'H'=>756,'I'=>308,'J'=>314,'K'=>676,'L'=>552,'M'=>1041,'N'=>817,'O'=>729,'P'=>569,'Q'=>698,'R'=>674,'S'=>618,'T'=>673,'U'=>805,'V'=>753,'W'=>1238, |
|
| 12 | - 'X'=>716,'Y'=>754,'Z'=>599,'['=>315,'\\'=>463,']'=>315,'^'=>600,'_'=>547,'`'=>278,'a'=>581,'b'=>564,'c'=>440,'d'=>571,'e'=>450,'f'=>347,'g'=>628,'h'=>611,'i'=>283,'j'=>283,'k'=>560,'l'=>252,'m'=>976, |
|
| 13 | - 'n'=>595,'o'=>508,'p'=>549,'q'=>540,'r'=>395,'s'=>441,'t'=>307,'u'=>614,'v'=>556,'w'=>915,'x'=>559,'y'=>597,'z'=>452,'{'=>315,'|'=>222,'}'=>315,'~'=>600,chr(127)=>800,chr(128)=>800,chr(129)=>800,chr(130)=>0,chr(131)=>0, |
|
| 14 | - chr(132)=>0,chr(133)=>780,chr(134)=>0,chr(135)=>0,chr(136)=>278,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>1064,chr(141)=>800,chr(142)=>0,chr(143)=>800,chr(144)=>800,chr(145)=>259,chr(146)=>259,chr(147)=>470,chr(148)=>470,chr(149)=>500,chr(150)=>300,chr(151)=>600,chr(152)=>278,chr(153)=>990, |
|
| 15 | - chr(154)=>0,chr(155)=>0,chr(156)=>790,chr(157)=>800,chr(158)=>800,chr(159)=>754,chr(160)=>282,chr(161)=>324,chr(162)=>450,chr(163)=>640,chr(164)=>518,chr(165)=>603,chr(166)=>0,chr(167)=>519,chr(168)=>254,chr(169)=>800,chr(170)=>349,chr(171)=>0,chr(172)=>0,chr(173)=>432,chr(174)=>800,chr(175)=>278, |
|
| 16 | - chr(176)=>0,chr(177)=>0,chr(178)=>0,chr(179)=>0,chr(180)=>278,chr(181)=>614,chr(182)=>0,chr(183)=>254,chr(184)=>278,chr(185)=>0,chr(186)=>305,chr(187)=>0,chr(188)=>0,chr(189)=>0,chr(190)=>0,chr(191)=>501,chr(192)=>743,chr(193)=>743,chr(194)=>743,chr(195)=>743,chr(196)=>743,chr(197)=>743, |
|
| 17 | - chr(198)=>1060,chr(199)=>598,chr(200)=>608,chr(201)=>608,chr(202)=>608,chr(203)=>608,chr(204)=>308,chr(205)=>308,chr(206)=>308,chr(207)=>308,chr(208)=>0,chr(209)=>817,chr(210)=>729,chr(211)=>729,chr(212)=>729,chr(213)=>729,chr(214)=>729,chr(215)=>0,chr(216)=>729,chr(217)=>805,chr(218)=>805,chr(219)=>805, |
|
| 18 | - chr(220)=>805,chr(221)=>0,chr(222)=>0,chr(223)=>688,chr(224)=>581,chr(225)=>581,chr(226)=>581,chr(227)=>581,chr(228)=>581,chr(229)=>581,chr(230)=>792,chr(231)=>440,chr(232)=>450,chr(233)=>450,chr(234)=>450,chr(235)=>450,chr(236)=>283,chr(237)=>283,chr(238)=>283,chr(239)=>283,chr(240)=>0,chr(241)=>595, |
|
| 19 | - chr(242)=>508,chr(243)=>508,chr(244)=>508,chr(245)=>508,chr(246)=>508,chr(247)=>0,chr(248)=>508,chr(249)=>614,chr(250)=>614,chr(251)=>614,chr(252)=>614,chr(253)=>0,chr(254)=>0,chr(255)=>597); |
|
| 8 | + chr(0)=>800, chr(1)=>800, chr(2)=>800, chr(3)=>800, chr(4)=>800, chr(5)=>800, chr(6)=>800, chr(7)=>800, chr(8)=>800, chr(9)=>800, chr(10)=>800, chr(11)=>800, chr(12)=>800, chr(13)=>800, chr(14)=>800, chr(15)=>800, chr(16)=>800, chr(17)=>800, chr(18)=>800, chr(19)=>800, chr(20)=>800, chr(21)=>800, |
|
| 9 | + chr(22)=>800, chr(23)=>800, chr(24)=>800, chr(25)=>800, chr(26)=>800, chr(27)=>800, chr(28)=>800, chr(29)=>800, chr(30)=>800, chr(31)=>800, ' '=>282, '!'=>324, '"'=>405, '#'=>584, '$'=>632, '%'=>980, '&'=>776, '\''=>259, '('=>299, ')'=>299, '*'=>377, '+'=>600, |
|
| 10 | + ','=>259, '-'=>432, '.'=>254, '/'=>597, '0'=>529, '1'=>298, '2'=>451, '3'=>359, '4'=>525, '5'=>423, '6'=>464, '7'=>417, '8'=>457, '9'=>479, ':'=>275, ';'=>282, '<'=>600, '='=>600, '>'=>600, '?'=>501, '@'=>800, 'A'=>743, |
|
| 11 | + 'B'=>636, 'C'=>598, 'D'=>712, 'E'=>608, 'F'=>562, 'G'=>680, 'H'=>756, 'I'=>308, 'J'=>314, 'K'=>676, 'L'=>552, 'M'=>1041, 'N'=>817, 'O'=>729, 'P'=>569, 'Q'=>698, 'R'=>674, 'S'=>618, 'T'=>673, 'U'=>805, 'V'=>753, 'W'=>1238, |
|
| 12 | + 'X'=>716, 'Y'=>754, 'Z'=>599, '['=>315, '\\'=>463, ']'=>315, '^'=>600, '_'=>547, '`'=>278, 'a'=>581, 'b'=>564, 'c'=>440, 'd'=>571, 'e'=>450, 'f'=>347, 'g'=>628, 'h'=>611, 'i'=>283, 'j'=>283, 'k'=>560, 'l'=>252, 'm'=>976, |
|
| 13 | + 'n'=>595, 'o'=>508, 'p'=>549, 'q'=>540, 'r'=>395, 's'=>441, 't'=>307, 'u'=>614, 'v'=>556, 'w'=>915, 'x'=>559, 'y'=>597, 'z'=>452, '{'=>315, '|'=>222, '}'=>315, '~'=>600, chr(127)=>800, chr(128)=>800, chr(129)=>800, chr(130)=>0, chr(131)=>0, |
|
| 14 | + chr(132)=>0, chr(133)=>780, chr(134)=>0, chr(135)=>0, chr(136)=>278, chr(137)=>0, chr(138)=>0, chr(139)=>0, chr(140)=>1064, chr(141)=>800, chr(142)=>0, chr(143)=>800, chr(144)=>800, chr(145)=>259, chr(146)=>259, chr(147)=>470, chr(148)=>470, chr(149)=>500, chr(150)=>300, chr(151)=>600, chr(152)=>278, chr(153)=>990, |
|
| 15 | + chr(154)=>0, chr(155)=>0, chr(156)=>790, chr(157)=>800, chr(158)=>800, chr(159)=>754, chr(160)=>282, chr(161)=>324, chr(162)=>450, chr(163)=>640, chr(164)=>518, chr(165)=>603, chr(166)=>0, chr(167)=>519, chr(168)=>254, chr(169)=>800, chr(170)=>349, chr(171)=>0, chr(172)=>0, chr(173)=>432, chr(174)=>800, chr(175)=>278, |
|
| 16 | + chr(176)=>0, chr(177)=>0, chr(178)=>0, chr(179)=>0, chr(180)=>278, chr(181)=>614, chr(182)=>0, chr(183)=>254, chr(184)=>278, chr(185)=>0, chr(186)=>305, chr(187)=>0, chr(188)=>0, chr(189)=>0, chr(190)=>0, chr(191)=>501, chr(192)=>743, chr(193)=>743, chr(194)=>743, chr(195)=>743, chr(196)=>743, chr(197)=>743, |
|
| 17 | + chr(198)=>1060, chr(199)=>598, chr(200)=>608, chr(201)=>608, chr(202)=>608, chr(203)=>608, chr(204)=>308, chr(205)=>308, chr(206)=>308, chr(207)=>308, chr(208)=>0, chr(209)=>817, chr(210)=>729, chr(211)=>729, chr(212)=>729, chr(213)=>729, chr(214)=>729, chr(215)=>0, chr(216)=>729, chr(217)=>805, chr(218)=>805, chr(219)=>805, |
|
| 18 | + chr(220)=>805, chr(221)=>0, chr(222)=>0, chr(223)=>688, chr(224)=>581, chr(225)=>581, chr(226)=>581, chr(227)=>581, chr(228)=>581, chr(229)=>581, chr(230)=>792, chr(231)=>440, chr(232)=>450, chr(233)=>450, chr(234)=>450, chr(235)=>450, chr(236)=>283, chr(237)=>283, chr(238)=>283, chr(239)=>283, chr(240)=>0, chr(241)=>595, |
|
| 19 | + chr(242)=>508, chr(243)=>508, chr(244)=>508, chr(245)=>508, chr(246)=>508, chr(247)=>0, chr(248)=>508, chr(249)=>614, chr(250)=>614, chr(251)=>614, chr(252)=>614, chr(253)=>0, chr(254)=>0, chr(255)=>597); |
|
| 20 | 20 | $enc = 'cp1252'; |
| 21 | -$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 | +$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)); |
|
| 22 | 22 | $file = 'calligra.z'; |
| 23 | 23 | $originalsize = 33948; |
| 24 | 24 | $subsetted = true; |
@@ -5,18 +5,18 @@ |
||
| 5 | 5 | $up = -106; |
| 6 | 6 | $ut = 73; |
| 7 | 7 | $cw = array( |
| 8 | - chr(0)=>750,chr(1)=>750,chr(2)=>750,chr(3)=>750,chr(4)=>750,chr(5)=>750,chr(6)=>750,chr(7)=>750,chr(8)=>750,chr(9)=>750,chr(10)=>750,chr(11)=>750,chr(12)=>750,chr(13)=>750,chr(14)=>750,chr(15)=>750,chr(16)=>750,chr(17)=>750,chr(18)=>750,chr(19)=>750,chr(20)=>750,chr(21)=>750, |
|
| 9 | - chr(22)=>750,chr(23)=>750,chr(24)=>750,chr(25)=>750,chr(26)=>750,chr(27)=>750,chr(28)=>750,chr(29)=>750,chr(30)=>750,chr(31)=>750,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, |
|
| 10 | - ','=>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, |
|
| 11 | - '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, |
|
| 12 | - '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, |
|
| 13 | - '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)=>750,chr(128)=>708,chr(129)=>625,chr(130)=>708,chr(131)=>708, |
|
| 14 | - chr(132)=>708,chr(133)=>708,chr(134)=>708,chr(135)=>708,chr(136)=>708,chr(137)=>708,chr(138)=>708,chr(139)=>708,chr(140)=>708,chr(141)=>708,chr(142)=>708,chr(143)=>708,chr(144)=>708,chr(145)=>708,chr(146)=>729,chr(147)=>604,chr(148)=>604,chr(149)=>278,chr(150)=>549,chr(151)=>549,chr(152)=>549,chr(153)=>549, |
|
| 15 | - chr(154)=>278,chr(155)=>604,chr(156)=>400,chr(157)=>333,chr(158)=>333,chr(159)=>549,chr(160)=>708,chr(161)=>708,chr(162)=>708,chr(163)=>556,chr(164)=>708,chr(165)=>708,chr(166)=>708,chr(167)=>708,chr(168)=>708,chr(169)=>708,chr(170)=>708,chr(171)=>708,chr(172)=>708,chr(173)=>708,chr(174)=>708,chr(175)=>708, |
|
| 16 | - chr(176)=>708,chr(177)=>708,chr(178)=>708,chr(179)=>667,chr(180)=>708,chr(181)=>708,chr(182)=>708,chr(183)=>708,chr(184)=>708,chr(185)=>708,chr(186)=>708,chr(187)=>708,chr(188)=>708,chr(189)=>708,chr(190)=>708,chr(191)=>737,chr(192)=>752,chr(193)=>556,chr(194)=>563,chr(195)=>572,chr(196)=>553,chr(197)=>556, |
|
| 17 | - chr(198)=>835,chr(199)=>493,chr(200)=>500,chr(201)=>556,chr(202)=>556,chr(203)=>472,chr(204)=>564,chr(205)=>686,chr(206)=>550,chr(207)=>556,chr(208)=>550,chr(209)=>534,chr(210)=>556,chr(211)=>500,chr(212)=>833,chr(213)=>500,chr(214)=>688,chr(215)=>522,chr(216)=>526,chr(217)=>736,chr(218)=>465,chr(219)=>830, |
|
| 18 | - chr(220)=>492,chr(221)=>851,chr(222)=>518,chr(223)=>621,chr(224)=>1022,chr(225)=>667,chr(226)=>651,chr(227)=>727,chr(228)=>704,chr(229)=>667,chr(230)=>795,chr(231)=>544,chr(232)=>667,chr(233)=>715,chr(234)=>715,chr(235)=>589,chr(236)=>686,chr(237)=>833,chr(238)=>722,chr(239)=>778,chr(240)=>725,chr(241)=>682, |
|
| 19 | - chr(242)=>667,chr(243)=>722,chr(244)=>611,chr(245)=>639,chr(246)=>917,chr(247)=>667,chr(248)=>651,chr(249)=>886,chr(250)=>614,chr(251)=>920,chr(252)=>694,chr(253)=>923,chr(254)=>673,chr(255)=>805); |
|
| 8 | + chr(0)=>750,chr(1)=>750,chr(2)=>750,chr(3)=>750,chr(4)=>750,chr(5)=>750,chr(6)=>750,chr(7)=>750,chr(8)=>750,chr(9)=>750,chr(10)=>750,chr(11)=>750,chr(12)=>750,chr(13)=>750,chr(14)=>750,chr(15)=>750,chr(16)=>750,chr(17)=>750,chr(18)=>750,chr(19)=>750,chr(20)=>750,chr(21)=>750, |
|
| 9 | + chr(22)=>750,chr(23)=>750,chr(24)=>750,chr(25)=>750,chr(26)=>750,chr(27)=>750,chr(28)=>750,chr(29)=>750,chr(30)=>750,chr(31)=>750,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, |
|
| 10 | + ','=>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, |
|
| 11 | + '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, |
|
| 12 | + '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, |
|
| 13 | + '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)=>750,chr(128)=>708,chr(129)=>625,chr(130)=>708,chr(131)=>708, |
|
| 14 | + chr(132)=>708,chr(133)=>708,chr(134)=>708,chr(135)=>708,chr(136)=>708,chr(137)=>708,chr(138)=>708,chr(139)=>708,chr(140)=>708,chr(141)=>708,chr(142)=>708,chr(143)=>708,chr(144)=>708,chr(145)=>708,chr(146)=>729,chr(147)=>604,chr(148)=>604,chr(149)=>278,chr(150)=>549,chr(151)=>549,chr(152)=>549,chr(153)=>549, |
|
| 15 | + chr(154)=>278,chr(155)=>604,chr(156)=>400,chr(157)=>333,chr(158)=>333,chr(159)=>549,chr(160)=>708,chr(161)=>708,chr(162)=>708,chr(163)=>556,chr(164)=>708,chr(165)=>708,chr(166)=>708,chr(167)=>708,chr(168)=>708,chr(169)=>708,chr(170)=>708,chr(171)=>708,chr(172)=>708,chr(173)=>708,chr(174)=>708,chr(175)=>708, |
|
| 16 | + chr(176)=>708,chr(177)=>708,chr(178)=>708,chr(179)=>667,chr(180)=>708,chr(181)=>708,chr(182)=>708,chr(183)=>708,chr(184)=>708,chr(185)=>708,chr(186)=>708,chr(187)=>708,chr(188)=>708,chr(189)=>708,chr(190)=>708,chr(191)=>737,chr(192)=>752,chr(193)=>556,chr(194)=>563,chr(195)=>572,chr(196)=>553,chr(197)=>556, |
|
| 17 | + chr(198)=>835,chr(199)=>493,chr(200)=>500,chr(201)=>556,chr(202)=>556,chr(203)=>472,chr(204)=>564,chr(205)=>686,chr(206)=>550,chr(207)=>556,chr(208)=>550,chr(209)=>534,chr(210)=>556,chr(211)=>500,chr(212)=>833,chr(213)=>500,chr(214)=>688,chr(215)=>522,chr(216)=>526,chr(217)=>736,chr(218)=>465,chr(219)=>830, |
|
| 18 | + chr(220)=>492,chr(221)=>851,chr(222)=>518,chr(223)=>621,chr(224)=>1022,chr(225)=>667,chr(226)=>651,chr(227)=>727,chr(228)=>704,chr(229)=>667,chr(230)=>795,chr(231)=>544,chr(232)=>667,chr(233)=>715,chr(234)=>715,chr(235)=>589,chr(236)=>686,chr(237)=>833,chr(238)=>722,chr(239)=>778,chr(240)=>725,chr(241)=>682, |
|
| 19 | + chr(242)=>667,chr(243)=>722,chr(244)=>611,chr(245)=>639,chr(246)=>917,chr(247)=>667,chr(248)=>651,chr(249)=>886,chr(250)=>614,chr(251)=>920,chr(252)=>694,chr(253)=>923,chr(254)=>673,chr(255)=>805); |
|
| 20 | 20 | $enc = 'KOI8-R'; |
| 21 | 21 | $diff = '128 /SF100000 /SF110000 /SF010000 /SF030000 /SF020000 /SF040000 /SF080000 /SF090000 /SF060000 /SF070000 /SF050000 /upblock /dnblock /block /lfblock /rtblock /ltshade /shade /dkshade /integraltp /filledbox /periodcentered /radical /approxequal /lessequal /greaterequal /space /integralbt /degree /twosuperior /periodcentered /divide /SF430000 /SF240000 /SF510000 /afii10071 /SF520000 /SF390000 /SF220000 /SF210000 /SF250000 /SF500000 /SF490000 /SF380000 /SF280000 /SF270000 /SF260000 /SF360000 /SF370000 /SF420000 /SF190000 /afii10023 /SF200000 /SF230000 /SF470000 /SF480000 /SF410000 /SF450000 /SF460000 /SF400000 /SF540000 /SF530000 /SF440000 /copyright /afii10096 /afii10065 /afii10066 /afii10088 /afii10069 /afii10070 /afii10086 /afii10068 /afii10087 /afii10074 /afii10075 /afii10076 /afii10077 /afii10078 /afii10079 /afii10080 /afii10081 /afii10097 /afii10082 /afii10083 /afii10084 /afii10085 /afii10072 /afii10067 /afii10094 /afii10093 /afii10073 /afii10090 /afii10095 /afii10091 /afii10089 /afii10092 /afii10048 /afii10017 /afii10018 /afii10040 /afii10021 /afii10022 /afii10038 /afii10020 /afii10039 /afii10026 /afii10027 /afii10028 /afii10029 /afii10030 /afii10031 /afii10032 /afii10033 /afii10049 /afii10034 /afii10035 /afii10036 /afii10037 /afii10024 /afii10019 /afii10046 /afii10045 /afii10025 /afii10042 /afii10047 /afii10043 /afii10041 /afii10044'; |
| 22 | 22 | $uv = array(0=>array(0,128),128=>9472,129=>9474,130=>9484,131=>9488,132=>9492,133=>9496,134=>9500,135=>9508,136=>9516,137=>9524,138=>9532,139=>9600,140=>9604,141=>9608,142=>9612,143=>array(9616,4),147=>8992,148=>9632,149=>array(8729,2),151=>8776,152=>array(8804,2),154=>160,155=>8993,156=>176,157=>178,158=>183,159=>247,160=>array(9552,3),163=>1105,164=>array(9555,15),179=>1025,180=>array(9570,11),191=>169,192=>1102,193=>array(1072,2),195=>1094,196=>array(1076,2),198=>1092,199=>1075,200=>1093,201=>array(1080,8),209=>1103,210=>array(1088,4),214=>1078,215=>1074,216=>1100,217=>1099,218=>1079,219=>1096,220=>1101,221=>1097,222=>1095,223=>1098,224=>1070,225=>array(1040,2),227=>1062,228=>array(1044,2),230=>1060,231=>1043,232=>1061,233=>array(1048,8),241=>1071,242=>array(1056,4),246=>1046,247=>1042,248=>1068,249=>1067,250=>1047,251=>1064,252=>1069,253=>1065,254=>1063,255=>1066); |
@@ -1,25 +1,25 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | $type = 'TrueType'; |
| 3 | 3 | $name = 'Arimo-Italic'; |
| 4 | -$desc = array('Ascent'=>728,'Descent'=>-208,'CapHeight'=>688,'Flags'=>96,'FontBBox'=>'[-664 -303 1361 1014]','ItalicAngle'=>-12,'StemV'=>70,'MissingWidth'=>750); |
|
| 4 | +$desc = array('Ascent'=>728, 'Descent'=>-208, 'CapHeight'=>688, 'Flags'=>96, 'FontBBox'=>'[-664 -303 1361 1014]', 'ItalicAngle'=>-12, 'StemV'=>70, 'MissingWidth'=>750); |
|
| 5 | 5 | $up = -106; |
| 6 | 6 | $ut = 73; |
| 7 | 7 | $cw = array( |
| 8 | - chr(0)=>750,chr(1)=>750,chr(2)=>750,chr(3)=>750,chr(4)=>750,chr(5)=>750,chr(6)=>750,chr(7)=>750,chr(8)=>750,chr(9)=>750,chr(10)=>750,chr(11)=>750,chr(12)=>750,chr(13)=>750,chr(14)=>750,chr(15)=>750,chr(16)=>750,chr(17)=>750,chr(18)=>750,chr(19)=>750,chr(20)=>750,chr(21)=>750, |
|
| 9 | - chr(22)=>750,chr(23)=>750,chr(24)=>750,chr(25)=>750,chr(26)=>750,chr(27)=>750,chr(28)=>750,chr(29)=>750,chr(30)=>750,chr(31)=>750,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, |
|
| 10 | - ','=>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, |
|
| 11 | - '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, |
|
| 12 | - '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, |
|
| 13 | - '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)=>750,chr(128)=>708,chr(129)=>625,chr(130)=>708,chr(131)=>708, |
|
| 14 | - chr(132)=>708,chr(133)=>708,chr(134)=>708,chr(135)=>708,chr(136)=>708,chr(137)=>708,chr(138)=>708,chr(139)=>708,chr(140)=>708,chr(141)=>708,chr(142)=>708,chr(143)=>708,chr(144)=>708,chr(145)=>708,chr(146)=>729,chr(147)=>604,chr(148)=>604,chr(149)=>278,chr(150)=>549,chr(151)=>549,chr(152)=>549,chr(153)=>549, |
|
| 15 | - chr(154)=>278,chr(155)=>604,chr(156)=>400,chr(157)=>333,chr(158)=>333,chr(159)=>549,chr(160)=>708,chr(161)=>708,chr(162)=>708,chr(163)=>556,chr(164)=>708,chr(165)=>708,chr(166)=>708,chr(167)=>708,chr(168)=>708,chr(169)=>708,chr(170)=>708,chr(171)=>708,chr(172)=>708,chr(173)=>708,chr(174)=>708,chr(175)=>708, |
|
| 16 | - chr(176)=>708,chr(177)=>708,chr(178)=>708,chr(179)=>667,chr(180)=>708,chr(181)=>708,chr(182)=>708,chr(183)=>708,chr(184)=>708,chr(185)=>708,chr(186)=>708,chr(187)=>708,chr(188)=>708,chr(189)=>708,chr(190)=>708,chr(191)=>737,chr(192)=>752,chr(193)=>556,chr(194)=>563,chr(195)=>572,chr(196)=>553,chr(197)=>556, |
|
| 17 | - chr(198)=>835,chr(199)=>493,chr(200)=>500,chr(201)=>556,chr(202)=>556,chr(203)=>472,chr(204)=>564,chr(205)=>686,chr(206)=>550,chr(207)=>556,chr(208)=>550,chr(209)=>534,chr(210)=>556,chr(211)=>500,chr(212)=>833,chr(213)=>500,chr(214)=>688,chr(215)=>522,chr(216)=>526,chr(217)=>736,chr(218)=>465,chr(219)=>830, |
|
| 18 | - chr(220)=>492,chr(221)=>851,chr(222)=>518,chr(223)=>621,chr(224)=>1022,chr(225)=>667,chr(226)=>651,chr(227)=>727,chr(228)=>704,chr(229)=>667,chr(230)=>795,chr(231)=>544,chr(232)=>667,chr(233)=>715,chr(234)=>715,chr(235)=>589,chr(236)=>686,chr(237)=>833,chr(238)=>722,chr(239)=>778,chr(240)=>725,chr(241)=>682, |
|
| 19 | - chr(242)=>667,chr(243)=>722,chr(244)=>611,chr(245)=>639,chr(246)=>917,chr(247)=>667,chr(248)=>651,chr(249)=>886,chr(250)=>614,chr(251)=>920,chr(252)=>694,chr(253)=>923,chr(254)=>673,chr(255)=>805); |
|
| 8 | + chr(0)=>750, chr(1)=>750, chr(2)=>750, chr(3)=>750, chr(4)=>750, chr(5)=>750, chr(6)=>750, chr(7)=>750, chr(8)=>750, chr(9)=>750, chr(10)=>750, chr(11)=>750, chr(12)=>750, chr(13)=>750, chr(14)=>750, chr(15)=>750, chr(16)=>750, chr(17)=>750, chr(18)=>750, chr(19)=>750, chr(20)=>750, chr(21)=>750, |
|
| 9 | + chr(22)=>750, chr(23)=>750, chr(24)=>750, chr(25)=>750, chr(26)=>750, chr(27)=>750, chr(28)=>750, chr(29)=>750, chr(30)=>750, chr(31)=>750, ' '=>278, '!'=>278, '"'=>355, '#'=>556, '$'=>556, '%'=>889, '&'=>667, '\''=>191, '('=>333, ')'=>333, '*'=>389, '+'=>584, |
|
| 10 | + ','=>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, |
|
| 11 | + '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, |
|
| 12 | + '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, |
|
| 13 | + '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)=>750, chr(128)=>708, chr(129)=>625, chr(130)=>708, chr(131)=>708, |
|
| 14 | + chr(132)=>708, chr(133)=>708, chr(134)=>708, chr(135)=>708, chr(136)=>708, chr(137)=>708, chr(138)=>708, chr(139)=>708, chr(140)=>708, chr(141)=>708, chr(142)=>708, chr(143)=>708, chr(144)=>708, chr(145)=>708, chr(146)=>729, chr(147)=>604, chr(148)=>604, chr(149)=>278, chr(150)=>549, chr(151)=>549, chr(152)=>549, chr(153)=>549, |
|
| 15 | + chr(154)=>278, chr(155)=>604, chr(156)=>400, chr(157)=>333, chr(158)=>333, chr(159)=>549, chr(160)=>708, chr(161)=>708, chr(162)=>708, chr(163)=>556, chr(164)=>708, chr(165)=>708, chr(166)=>708, chr(167)=>708, chr(168)=>708, chr(169)=>708, chr(170)=>708, chr(171)=>708, chr(172)=>708, chr(173)=>708, chr(174)=>708, chr(175)=>708, |
|
| 16 | + chr(176)=>708, chr(177)=>708, chr(178)=>708, chr(179)=>667, chr(180)=>708, chr(181)=>708, chr(182)=>708, chr(183)=>708, chr(184)=>708, chr(185)=>708, chr(186)=>708, chr(187)=>708, chr(188)=>708, chr(189)=>708, chr(190)=>708, chr(191)=>737, chr(192)=>752, chr(193)=>556, chr(194)=>563, chr(195)=>572, chr(196)=>553, chr(197)=>556, |
|
| 17 | + chr(198)=>835, chr(199)=>493, chr(200)=>500, chr(201)=>556, chr(202)=>556, chr(203)=>472, chr(204)=>564, chr(205)=>686, chr(206)=>550, chr(207)=>556, chr(208)=>550, chr(209)=>534, chr(210)=>556, chr(211)=>500, chr(212)=>833, chr(213)=>500, chr(214)=>688, chr(215)=>522, chr(216)=>526, chr(217)=>736, chr(218)=>465, chr(219)=>830, |
|
| 18 | + chr(220)=>492, chr(221)=>851, chr(222)=>518, chr(223)=>621, chr(224)=>1022, chr(225)=>667, chr(226)=>651, chr(227)=>727, chr(228)=>704, chr(229)=>667, chr(230)=>795, chr(231)=>544, chr(232)=>667, chr(233)=>715, chr(234)=>715, chr(235)=>589, chr(236)=>686, chr(237)=>833, chr(238)=>722, chr(239)=>778, chr(240)=>725, chr(241)=>682, |
|
| 19 | + chr(242)=>667, chr(243)=>722, chr(244)=>611, chr(245)=>639, chr(246)=>917, chr(247)=>667, chr(248)=>651, chr(249)=>886, chr(250)=>614, chr(251)=>920, chr(252)=>694, chr(253)=>923, chr(254)=>673, chr(255)=>805); |
|
| 20 | 20 | $enc = 'KOI8-R'; |
| 21 | 21 | $diff = '128 /SF100000 /SF110000 /SF010000 /SF030000 /SF020000 /SF040000 /SF080000 /SF090000 /SF060000 /SF070000 /SF050000 /upblock /dnblock /block /lfblock /rtblock /ltshade /shade /dkshade /integraltp /filledbox /periodcentered /radical /approxequal /lessequal /greaterequal /space /integralbt /degree /twosuperior /periodcentered /divide /SF430000 /SF240000 /SF510000 /afii10071 /SF520000 /SF390000 /SF220000 /SF210000 /SF250000 /SF500000 /SF490000 /SF380000 /SF280000 /SF270000 /SF260000 /SF360000 /SF370000 /SF420000 /SF190000 /afii10023 /SF200000 /SF230000 /SF470000 /SF480000 /SF410000 /SF450000 /SF460000 /SF400000 /SF540000 /SF530000 /SF440000 /copyright /afii10096 /afii10065 /afii10066 /afii10088 /afii10069 /afii10070 /afii10086 /afii10068 /afii10087 /afii10074 /afii10075 /afii10076 /afii10077 /afii10078 /afii10079 /afii10080 /afii10081 /afii10097 /afii10082 /afii10083 /afii10084 /afii10085 /afii10072 /afii10067 /afii10094 /afii10093 /afii10073 /afii10090 /afii10095 /afii10091 /afii10089 /afii10092 /afii10048 /afii10017 /afii10018 /afii10040 /afii10021 /afii10022 /afii10038 /afii10020 /afii10039 /afii10026 /afii10027 /afii10028 /afii10029 /afii10030 /afii10031 /afii10032 /afii10033 /afii10049 /afii10034 /afii10035 /afii10036 /afii10037 /afii10024 /afii10019 /afii10046 /afii10045 /afii10025 /afii10042 /afii10047 /afii10043 /afii10041 /afii10044'; |
| 22 | -$uv = array(0=>array(0,128),128=>9472,129=>9474,130=>9484,131=>9488,132=>9492,133=>9496,134=>9500,135=>9508,136=>9516,137=>9524,138=>9532,139=>9600,140=>9604,141=>9608,142=>9612,143=>array(9616,4),147=>8992,148=>9632,149=>array(8729,2),151=>8776,152=>array(8804,2),154=>160,155=>8993,156=>176,157=>178,158=>183,159=>247,160=>array(9552,3),163=>1105,164=>array(9555,15),179=>1025,180=>array(9570,11),191=>169,192=>1102,193=>array(1072,2),195=>1094,196=>array(1076,2),198=>1092,199=>1075,200=>1093,201=>array(1080,8),209=>1103,210=>array(1088,4),214=>1078,215=>1074,216=>1100,217=>1099,218=>1079,219=>1096,220=>1101,221=>1097,222=>1095,223=>1098,224=>1070,225=>array(1040,2),227=>1062,228=>array(1044,2),230=>1060,231=>1043,232=>1061,233=>array(1048,8),241=>1071,242=>array(1056,4),246=>1046,247=>1042,248=>1068,249=>1067,250=>1047,251=>1064,252=>1069,253=>1065,254=>1063,255=>1066); |
|
| 22 | +$uv = array(0=>array(0, 128), 128=>9472, 129=>9474, 130=>9484, 131=>9488, 132=>9492, 133=>9496, 134=>9500, 135=>9508, 136=>9516, 137=>9524, 138=>9532, 139=>9600, 140=>9604, 141=>9608, 142=>9612, 143=>array(9616, 4), 147=>8992, 148=>9632, 149=>array(8729, 2), 151=>8776, 152=>array(8804, 2), 154=>160, 155=>8993, 156=>176, 157=>178, 158=>183, 159=>247, 160=>array(9552, 3), 163=>1105, 164=>array(9555, 15), 179=>1025, 180=>array(9570, 11), 191=>169, 192=>1102, 193=>array(1072, 2), 195=>1094, 196=>array(1076, 2), 198=>1092, 199=>1075, 200=>1093, 201=>array(1080, 8), 209=>1103, 210=>array(1088, 4), 214=>1078, 215=>1074, 216=>1100, 217=>1099, 218=>1079, 219=>1096, 220=>1101, 221=>1097, 222=>1095, 223=>1098, 224=>1070, 225=>array(1040, 2), 227=>1062, 228=>array(1044, 2), 230=>1060, 231=>1043, 232=>1061, 233=>array(1048, 8), 241=>1071, 242=>array(1056, 4), 246=>1046, 247=>1042, 248=>1068, 249=>1067, 250=>1047, 251=>1064, 252=>1069, 253=>1065, 254=>1063, 255=>1066); |
|
| 23 | 23 | $file = 'Arimo-Italic.z'; |
| 24 | 24 | $originalsize = 44228; |
| 25 | 25 | $subsetted = true; |
@@ -73,961 +73,961 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | function __construct($orientation='P', $unit='mm', $size='A4') |
| 75 | 75 | { |
| 76 | - // Some checks |
|
| 77 | - $this->_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','verdana','calligra','Arimo-Regular'); |
|
| 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'; |
|
| 76 | + // Some checks |
|
| 77 | + $this->_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','verdana','calligra','Arimo-Regular'); |
|
| 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 | 170 | } |
| 171 | 171 | |
| 172 | 172 | function SetMargins($left, $top, $right=null) |
| 173 | 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; |
|
| 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 | 180 | } |
| 181 | 181 | |
| 182 | 182 | function SetLeftMargin($margin) |
| 183 | 183 | { |
| 184 | - // Set left margin |
|
| 185 | - $this->lMargin = $margin; |
|
| 186 | - if($this->page>0 && $this->x<$margin) |
|
| 187 | - $this->x = $margin; |
|
| 184 | + // Set left margin |
|
| 185 | + $this->lMargin = $margin; |
|
| 186 | + if($this->page>0 && $this->x<$margin) |
|
| 187 | + $this->x = $margin; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | function SetTopMargin($margin) |
| 191 | 191 | { |
| 192 | - // Set top margin |
|
| 193 | - $this->tMargin = $margin; |
|
| 192 | + // Set top margin |
|
| 193 | + $this->tMargin = $margin; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | function SetRightMargin($margin) |
| 197 | 197 | { |
| 198 | - // Set right margin |
|
| 199 | - $this->rMargin = $margin; |
|
| 198 | + // Set right margin |
|
| 199 | + $this->rMargin = $margin; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | function SetAutoPageBreak($auto, $margin=0) |
| 203 | 203 | { |
| 204 | - // Set auto page break mode and triggering margin |
|
| 205 | - $this->AutoPageBreak = $auto; |
|
| 206 | - $this->bMargin = $margin; |
|
| 207 | - $this->PageBreakTrigger = $this->h-$margin; |
|
| 204 | + // Set auto page break mode and triggering margin |
|
| 205 | + $this->AutoPageBreak = $auto; |
|
| 206 | + $this->bMargin = $margin; |
|
| 207 | + $this->PageBreakTrigger = $this->h-$margin; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | function SetDisplayMode($zoom, $layout='default') |
| 211 | 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); |
|
| 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 | 221 | } |
| 222 | 222 | |
| 223 | 223 | function SetCompression($compress) |
| 224 | 224 | { |
| 225 | - // Set page compression |
|
| 226 | - if(function_exists('gzcompress')) |
|
| 227 | - $this->compress = $compress; |
|
| 228 | - else |
|
| 229 | - $this->compress = false; |
|
| 225 | + // Set page compression |
|
| 226 | + if(function_exists('gzcompress')) |
|
| 227 | + $this->compress = $compress; |
|
| 228 | + else |
|
| 229 | + $this->compress = false; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | function SetTitle($title, $isUTF8=false) |
| 233 | 233 | { |
| 234 | - // Title of document |
|
| 235 | - $this->metadata['Title'] = $isUTF8 ? $title : utf8_encode($title); |
|
| 234 | + // Title of document |
|
| 235 | + $this->metadata['Title'] = $isUTF8 ? $title : utf8_encode($title); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | function SetAuthor($author, $isUTF8=false) |
| 239 | 239 | { |
| 240 | - // Author of document |
|
| 241 | - $this->metadata['Author'] = $isUTF8 ? $author : utf8_encode($author); |
|
| 240 | + // Author of document |
|
| 241 | + $this->metadata['Author'] = $isUTF8 ? $author : utf8_encode($author); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function SetSubject($subject, $isUTF8=false) |
| 245 | 245 | { |
| 246 | - // Subject of document |
|
| 247 | - $this->metadata['Subject'] = $isUTF8 ? $subject : utf8_encode($subject); |
|
| 246 | + // Subject of document |
|
| 247 | + $this->metadata['Subject'] = $isUTF8 ? $subject : utf8_encode($subject); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | function SetKeywords($keywords, $isUTF8=false) |
| 251 | 251 | { |
| 252 | - // Keywords of document |
|
| 253 | - $this->metadata['Keywords'] = $isUTF8 ? $keywords : utf8_encode($keywords); |
|
| 252 | + // Keywords of document |
|
| 253 | + $this->metadata['Keywords'] = $isUTF8 ? $keywords : utf8_encode($keywords); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | function SetCreator($creator, $isUTF8=false) |
| 257 | 257 | { |
| 258 | - // Creator of document |
|
| 259 | - $this->metadata['Creator'] = $isUTF8 ? $creator : utf8_encode($creator); |
|
| 258 | + // Creator of document |
|
| 259 | + $this->metadata['Creator'] = $isUTF8 ? $creator : utf8_encode($creator); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | function AliasNbPages($alias='{nb}') |
| 263 | 263 | { |
| 264 | - // Define an alias for total number of pages |
|
| 265 | - $this->AliasNbPages = $alias; |
|
| 264 | + // Define an alias for total number of pages |
|
| 265 | + $this->AliasNbPages = $alias; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | function Error($msg) |
| 269 | 269 | { |
| 270 | - // Fatal error |
|
| 271 | - throw new Exception('FPDF error: '.$msg); |
|
| 270 | + // Fatal error |
|
| 271 | + throw new Exception('FPDF error: '.$msg); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | function Close() |
| 275 | 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(); |
|
| 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 | 289 | } |
| 290 | 290 | |
| 291 | 291 | function AddPage($orientation='', $size='', $rotation=0) |
| 292 | 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; |
|
| 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 | 358 | } |
| 359 | 359 | |
| 360 | 360 | function Header() |
| 361 | 361 | { |
| 362 | - // To be implemented in your own inherited class |
|
| 362 | + // To be implemented in your own inherited class |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | function Footer() |
| 366 | 366 | { |
| 367 | - // To be implemented in your own inherited class |
|
| 367 | + // To be implemented in your own inherited class |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | function PageNo() |
| 371 | 371 | { |
| 372 | - // Get current page number |
|
| 373 | - return $this->page; |
|
| 372 | + // Get current page number |
|
| 373 | + return $this->page; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | function SetDrawColor($r, $g=null, $b=null) |
| 377 | 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); |
|
| 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 | 385 | } |
| 386 | 386 | |
| 387 | 387 | function SetFillColor($r, $g=null, $b=null) |
| 388 | 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); |
|
| 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 | 397 | } |
| 398 | 398 | |
| 399 | 399 | function SetTextColor($r, $g=null, $b=null) |
| 400 | 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); |
|
| 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 | 407 | } |
| 408 | 408 | |
| 409 | 409 | function GetStringWidth($s) |
| 410 | 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; |
|
| 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 | 419 | } |
| 420 | 420 | |
| 421 | 421 | function SetLineWidth($width) |
| 422 | 422 | { |
| 423 | - // Set line width |
|
| 424 | - $this->LineWidth = $width; |
|
| 425 | - if($this->page>0) |
|
| 426 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 423 | + // Set line width |
|
| 424 | + $this->LineWidth = $width; |
|
| 425 | + if($this->page>0) |
|
| 426 | + $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | function Line($x1, $y1, $x2, $y2) |
| 430 | 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)); |
|
| 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 | 433 | } |
| 434 | 434 | |
| 435 | 435 | function Rect($x, $y, $w, $h, $style='') |
| 436 | 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)); |
|
| 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 | 445 | } |
| 446 | 446 | |
| 447 | 447 | function AddFont($family, $style='', $file='') |
| 448 | 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; |
|
| 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 | 470 | } |
| 471 | 471 | |
| 472 | 472 | function SetFont($family, $style='', $size=0) |
| 473 | 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)); |
|
| 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 | 520 | } |
| 521 | 521 | |
| 522 | 522 | function SetFontSize($size) |
| 523 | 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)); |
|
| 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 | 531 | } |
| 532 | 532 | |
| 533 | 533 | function AddLink() |
| 534 | 534 | { |
| 535 | - // Create a new internal link |
|
| 536 | - $n = count($this->links)+1; |
|
| 537 | - $this->links[$n] = array(0, 0); |
|
| 538 | - return $n; |
|
| 535 | + // Create a new internal link |
|
| 536 | + $n = count($this->links)+1; |
|
| 537 | + $this->links[$n] = array(0, 0); |
|
| 538 | + return $n; |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | function SetLink($link, $y=0, $page=-1) |
| 542 | 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); |
|
| 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 | 549 | } |
| 550 | 550 | |
| 551 | 551 | function Link($x, $y, $w, $h, $link) |
| 552 | 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); |
|
| 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 | 555 | } |
| 556 | 556 | |
| 557 | 557 | function Text($x, $y, $txt) |
| 558 | 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); |
|
| 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 | 568 | } |
| 569 | 569 | |
| 570 | 570 | function AcceptPageBreak() |
| 571 | 571 | { |
| 572 | - // Accept automatic page break or not |
|
| 573 | - return $this->AutoPageBreak; |
|
| 572 | + // Accept automatic page break or not |
|
| 573 | + return $this->AutoPageBreak; |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') |
| 577 | 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; |
|
| 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 | 654 | } |
| 655 | 655 | |
| 656 | 656 | function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
| 657 | 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; |
|
| 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 | 769 | } |
| 770 | 770 | |
| 771 | 771 | function Write($h, $txt, $link='') |
| 772 | 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); |
|
| 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 | 852 | } |
| 853 | 853 | |
| 854 | 854 | function Ln($h=null) |
| 855 | 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; |
|
| 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 | 862 | } |
| 863 | 863 | |
| 864 | 864 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
| 865 | 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); |
|
| 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 | 927 | } |
| 928 | 928 | |
| 929 | 929 | function GetPageWidth() |
| 930 | 930 | { |
| 931 | - // Get current page width |
|
| 932 | - return $this->w; |
|
| 931 | + // Get current page width |
|
| 932 | + return $this->w; |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | function GetPageHeight() |
| 936 | 936 | { |
| 937 | - // Get current page height |
|
| 938 | - return $this->h; |
|
| 937 | + // Get current page height |
|
| 938 | + return $this->h; |
|
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | function GetX() |
| 942 | 942 | { |
| 943 | - // Get x position |
|
| 944 | - return $this->x; |
|
| 943 | + // Get x position |
|
| 944 | + return $this->x; |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | function SetX($x) |
| 948 | 948 | { |
| 949 | - // Set x position |
|
| 950 | - if($x>=0) |
|
| 951 | - $this->x = $x; |
|
| 952 | - else |
|
| 953 | - $this->x = $this->w+$x; |
|
| 949 | + // Set x position |
|
| 950 | + if($x>=0) |
|
| 951 | + $this->x = $x; |
|
| 952 | + else |
|
| 953 | + $this->x = $this->w+$x; |
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | function GetY() |
| 957 | 957 | { |
| 958 | - // Get y position |
|
| 959 | - return $this->y; |
|
| 958 | + // Get y position |
|
| 959 | + return $this->y; |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | function SetY($y, $resetX=true) |
| 963 | 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; |
|
| 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 | 971 | } |
| 972 | 972 | |
| 973 | 973 | function SetXY($x, $y) |
| 974 | 974 | { |
| 975 | - // Set x and y positions |
|
| 976 | - $this->SetX($x); |
|
| 977 | - $this->SetY($y,false); |
|
| 975 | + // Set x and y positions |
|
| 976 | + $this->SetX($x); |
|
| 977 | + $this->SetY($y,false); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | function Output($dest='', $name='', $isUTF8=false) |
| 981 | 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 ''; |
|
| 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 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | /******************************************************************************* |
@@ -1036,875 +1036,875 @@ discard block |
||
| 1036 | 1036 | |
| 1037 | 1037 | protected function _dochecks() |
| 1038 | 1038 | { |
| 1039 | - // Check mbstring overloading |
|
| 1040 | - if(ini_get('mbstring.func_overload') & 2) |
|
| 1041 | - $this->Error('mbstring overloading must be disabled'); |
|
| 1039 | + // Check mbstring overloading |
|
| 1040 | + if(ini_get('mbstring.func_overload') & 2) |
|
| 1041 | + $this->Error('mbstring overloading must be disabled'); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | protected function _checkoutput() |
| 1045 | 1045 | { |
| 1046 | - if(PHP_SAPI!='cli') |
|
| 1047 | - { |
|
| 1048 | - if(headers_sent($file,$line)) |
|
| 1049 | - $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
| 1050 | - } |
|
| 1051 | - if(ob_get_length()) |
|
| 1052 | - { |
|
| 1053 | - // The output buffer is not empty |
|
| 1054 | - if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents())) |
|
| 1055 | - { |
|
| 1056 | - // It contains only a UTF-8 BOM and/or whitespace, let's clean it |
|
| 1057 | - ob_clean(); |
|
| 1058 | - } |
|
| 1059 | - else |
|
| 1060 | - $this->Error("Some data has already been output, can't send PDF file"); |
|
| 1061 | - } |
|
| 1046 | + if(PHP_SAPI!='cli') |
|
| 1047 | + { |
|
| 1048 | + if(headers_sent($file,$line)) |
|
| 1049 | + $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
| 1050 | + } |
|
| 1051 | + if(ob_get_length()) |
|
| 1052 | + { |
|
| 1053 | + // The output buffer is not empty |
|
| 1054 | + if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents())) |
|
| 1055 | + { |
|
| 1056 | + // It contains only a UTF-8 BOM and/or whitespace, let's clean it |
|
| 1057 | + ob_clean(); |
|
| 1058 | + } |
|
| 1059 | + else |
|
| 1060 | + $this->Error("Some data has already been output, can't send PDF file"); |
|
| 1061 | + } |
|
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | 1064 | protected function _getpagesize($size) |
| 1065 | 1065 | { |
| 1066 | - if(is_string($size)) |
|
| 1067 | - { |
|
| 1068 | - $size = strtolower($size); |
|
| 1069 | - if(!isset($this->StdPageSizes[$size])) |
|
| 1070 | - $this->Error('Unknown page size: '.$size); |
|
| 1071 | - $a = $this->StdPageSizes[$size]; |
|
| 1072 | - return array($a[0]/$this->k, $a[1]/$this->k); |
|
| 1073 | - } |
|
| 1074 | - else |
|
| 1075 | - { |
|
| 1076 | - if($size[0]>$size[1]) |
|
| 1077 | - return array($size[1], $size[0]); |
|
| 1078 | - else |
|
| 1079 | - return $size; |
|
| 1080 | - } |
|
| 1066 | + if(is_string($size)) |
|
| 1067 | + { |
|
| 1068 | + $size = strtolower($size); |
|
| 1069 | + if(!isset($this->StdPageSizes[$size])) |
|
| 1070 | + $this->Error('Unknown page size: '.$size); |
|
| 1071 | + $a = $this->StdPageSizes[$size]; |
|
| 1072 | + return array($a[0]/$this->k, $a[1]/$this->k); |
|
| 1073 | + } |
|
| 1074 | + else |
|
| 1075 | + { |
|
| 1076 | + if($size[0]>$size[1]) |
|
| 1077 | + return array($size[1], $size[0]); |
|
| 1078 | + else |
|
| 1079 | + return $size; |
|
| 1080 | + } |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | protected function _beginpage($orientation, $size, $rotation) |
| 1084 | 1084 | { |
| 1085 | - $this->page++; |
|
| 1086 | - $this->pages[$this->page] = ''; |
|
| 1087 | - $this->PageLinks[$this->page] = array(); |
|
| 1088 | - $this->state = 2; |
|
| 1089 | - $this->x = $this->lMargin; |
|
| 1090 | - $this->y = $this->tMargin; |
|
| 1091 | - $this->FontFamily = ''; |
|
| 1092 | - // Check page size and orientation |
|
| 1093 | - if($orientation=='') |
|
| 1094 | - $orientation = $this->DefOrientation; |
|
| 1095 | - else |
|
| 1096 | - $orientation = strtoupper($orientation[0]); |
|
| 1097 | - if($size=='') |
|
| 1098 | - $size = $this->DefPageSize; |
|
| 1099 | - else |
|
| 1100 | - $size = $this->_getpagesize($size); |
|
| 1101 | - if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) |
|
| 1102 | - { |
|
| 1103 | - // New size or orientation |
|
| 1104 | - if($orientation=='P') |
|
| 1105 | - { |
|
| 1106 | - $this->w = $size[0]; |
|
| 1107 | - $this->h = $size[1]; |
|
| 1108 | - } |
|
| 1109 | - else |
|
| 1110 | - { |
|
| 1111 | - $this->w = $size[1]; |
|
| 1112 | - $this->h = $size[0]; |
|
| 1113 | - } |
|
| 1114 | - $this->wPt = $this->w*$this->k; |
|
| 1115 | - $this->hPt = $this->h*$this->k; |
|
| 1116 | - $this->PageBreakTrigger = $this->h-$this->bMargin; |
|
| 1117 | - $this->CurOrientation = $orientation; |
|
| 1118 | - $this->CurPageSize = $size; |
|
| 1119 | - } |
|
| 1120 | - if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) |
|
| 1121 | - $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1122 | - if($rotation!=0) |
|
| 1123 | - { |
|
| 1124 | - if($rotation%90!=0) |
|
| 1125 | - $this->Error('Incorrect rotation value: '.$rotation); |
|
| 1126 | - $this->CurRotation = $rotation; |
|
| 1127 | - $this->PageInfo[$this->page]['rotation'] = $rotation; |
|
| 1128 | - } |
|
| 1085 | + $this->page++; |
|
| 1086 | + $this->pages[$this->page] = ''; |
|
| 1087 | + $this->PageLinks[$this->page] = array(); |
|
| 1088 | + $this->state = 2; |
|
| 1089 | + $this->x = $this->lMargin; |
|
| 1090 | + $this->y = $this->tMargin; |
|
| 1091 | + $this->FontFamily = ''; |
|
| 1092 | + // Check page size and orientation |
|
| 1093 | + if($orientation=='') |
|
| 1094 | + $orientation = $this->DefOrientation; |
|
| 1095 | + else |
|
| 1096 | + $orientation = strtoupper($orientation[0]); |
|
| 1097 | + if($size=='') |
|
| 1098 | + $size = $this->DefPageSize; |
|
| 1099 | + else |
|
| 1100 | + $size = $this->_getpagesize($size); |
|
| 1101 | + if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) |
|
| 1102 | + { |
|
| 1103 | + // New size or orientation |
|
| 1104 | + if($orientation=='P') |
|
| 1105 | + { |
|
| 1106 | + $this->w = $size[0]; |
|
| 1107 | + $this->h = $size[1]; |
|
| 1108 | + } |
|
| 1109 | + else |
|
| 1110 | + { |
|
| 1111 | + $this->w = $size[1]; |
|
| 1112 | + $this->h = $size[0]; |
|
| 1113 | + } |
|
| 1114 | + $this->wPt = $this->w*$this->k; |
|
| 1115 | + $this->hPt = $this->h*$this->k; |
|
| 1116 | + $this->PageBreakTrigger = $this->h-$this->bMargin; |
|
| 1117 | + $this->CurOrientation = $orientation; |
|
| 1118 | + $this->CurPageSize = $size; |
|
| 1119 | + } |
|
| 1120 | + if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) |
|
| 1121 | + $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1122 | + if($rotation!=0) |
|
| 1123 | + { |
|
| 1124 | + if($rotation%90!=0) |
|
| 1125 | + $this->Error('Incorrect rotation value: '.$rotation); |
|
| 1126 | + $this->CurRotation = $rotation; |
|
| 1127 | + $this->PageInfo[$this->page]['rotation'] = $rotation; |
|
| 1128 | + } |
|
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | protected function _endpage() |
| 1132 | 1132 | { |
| 1133 | - $this->state = 1; |
|
| 1133 | + $this->state = 1; |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | protected function _loadfont($font) |
| 1137 | 1137 | { |
| 1138 | - // Load a font definition file from the font directory |
|
| 1139 | - if(strpos($font,'/')!==false || strpos($font,"\\")!==false) |
|
| 1140 | - $this->Error('Incorrect font definition file name: '.$font); |
|
| 1141 | - include($this->fontpath.$font); |
|
| 1142 | - if(!isset($name)) |
|
| 1143 | - $this->Error('Could not include font definition file'); |
|
| 1144 | - if(isset($enc)) |
|
| 1145 | - $enc = strtolower($enc); |
|
| 1146 | - if(!isset($subsetted)) |
|
| 1147 | - $subsetted = false; |
|
| 1148 | - return get_defined_vars(); |
|
| 1138 | + // Load a font definition file from the font directory |
|
| 1139 | + if(strpos($font,'/')!==false || strpos($font,"\\")!==false) |
|
| 1140 | + $this->Error('Incorrect font definition file name: '.$font); |
|
| 1141 | + include($this->fontpath.$font); |
|
| 1142 | + if(!isset($name)) |
|
| 1143 | + $this->Error('Could not include font definition file'); |
|
| 1144 | + if(isset($enc)) |
|
| 1145 | + $enc = strtolower($enc); |
|
| 1146 | + if(!isset($subsetted)) |
|
| 1147 | + $subsetted = false; |
|
| 1148 | + return get_defined_vars(); |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | protected function _isascii($s) |
| 1152 | 1152 | { |
| 1153 | - // Test if string is ASCII |
|
| 1154 | - $nb = strlen($s); |
|
| 1155 | - for($i=0;$i<$nb;$i++) |
|
| 1156 | - { |
|
| 1157 | - if(ord($s[$i])>127) |
|
| 1158 | - return false; |
|
| 1159 | - } |
|
| 1160 | - return true; |
|
| 1153 | + // Test if string is ASCII |
|
| 1154 | + $nb = strlen($s); |
|
| 1155 | + for($i=0;$i<$nb;$i++) |
|
| 1156 | + { |
|
| 1157 | + if(ord($s[$i])>127) |
|
| 1158 | + return false; |
|
| 1159 | + } |
|
| 1160 | + return true; |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | protected function _httpencode($param, $value, $isUTF8) |
| 1164 | 1164 | { |
| 1165 | - // Encode HTTP header field parameter |
|
| 1166 | - if($this->_isascii($value)) |
|
| 1167 | - return $param.'="'.$value.'"'; |
|
| 1168 | - if(!$isUTF8) |
|
| 1169 | - $value = utf8_encode($value); |
|
| 1170 | - if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) |
|
| 1171 | - return $param.'="'.rawurlencode($value).'"'; |
|
| 1172 | - else |
|
| 1173 | - return $param."*=UTF-8''".rawurlencode($value); |
|
| 1165 | + // Encode HTTP header field parameter |
|
| 1166 | + if($this->_isascii($value)) |
|
| 1167 | + return $param.'="'.$value.'"'; |
|
| 1168 | + if(!$isUTF8) |
|
| 1169 | + $value = utf8_encode($value); |
|
| 1170 | + if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) |
|
| 1171 | + return $param.'="'.rawurlencode($value).'"'; |
|
| 1172 | + else |
|
| 1173 | + return $param."*=UTF-8''".rawurlencode($value); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | protected function _UTF8toUTF16($s) |
| 1177 | 1177 | { |
| 1178 | - // Convert UTF-8 to UTF-16BE with BOM |
|
| 1179 | - $res = "\xFE\xFF"; |
|
| 1180 | - $nb = strlen($s); |
|
| 1181 | - $i = 0; |
|
| 1182 | - while($i<$nb) |
|
| 1183 | - { |
|
| 1184 | - $c1 = ord($s[$i++]); |
|
| 1185 | - if($c1>=224) |
|
| 1186 | - { |
|
| 1187 | - // 3-byte character |
|
| 1188 | - $c2 = ord($s[$i++]); |
|
| 1189 | - $c3 = ord($s[$i++]); |
|
| 1190 | - $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
|
| 1191 | - $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
|
| 1192 | - } |
|
| 1193 | - elseif($c1>=192) |
|
| 1194 | - { |
|
| 1195 | - // 2-byte character |
|
| 1196 | - $c2 = ord($s[$i++]); |
|
| 1197 | - $res .= chr(($c1 & 0x1C)>>2); |
|
| 1198 | - $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
|
| 1199 | - } |
|
| 1200 | - else |
|
| 1201 | - { |
|
| 1202 | - // Single-byte character |
|
| 1203 | - $res .= "\0".chr($c1); |
|
| 1204 | - } |
|
| 1205 | - } |
|
| 1206 | - return $res; |
|
| 1178 | + // Convert UTF-8 to UTF-16BE with BOM |
|
| 1179 | + $res = "\xFE\xFF"; |
|
| 1180 | + $nb = strlen($s); |
|
| 1181 | + $i = 0; |
|
| 1182 | + while($i<$nb) |
|
| 1183 | + { |
|
| 1184 | + $c1 = ord($s[$i++]); |
|
| 1185 | + if($c1>=224) |
|
| 1186 | + { |
|
| 1187 | + // 3-byte character |
|
| 1188 | + $c2 = ord($s[$i++]); |
|
| 1189 | + $c3 = ord($s[$i++]); |
|
| 1190 | + $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
|
| 1191 | + $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
|
| 1192 | + } |
|
| 1193 | + elseif($c1>=192) |
|
| 1194 | + { |
|
| 1195 | + // 2-byte character |
|
| 1196 | + $c2 = ord($s[$i++]); |
|
| 1197 | + $res .= chr(($c1 & 0x1C)>>2); |
|
| 1198 | + $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
|
| 1199 | + } |
|
| 1200 | + else |
|
| 1201 | + { |
|
| 1202 | + // Single-byte character |
|
| 1203 | + $res .= "\0".chr($c1); |
|
| 1204 | + } |
|
| 1205 | + } |
|
| 1206 | + return $res; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | protected function _escape($s) |
| 1210 | 1210 | { |
| 1211 | - // Escape special characters |
|
| 1212 | - if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) |
|
| 1213 | - return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
| 1214 | - else |
|
| 1215 | - return $s; |
|
| 1211 | + // Escape special characters |
|
| 1212 | + if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) |
|
| 1213 | + return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
| 1214 | + else |
|
| 1215 | + return $s; |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | protected function _textstring($s) |
| 1219 | 1219 | { |
| 1220 | - // Format a text string |
|
| 1221 | - if(!$this->_isascii($s)) |
|
| 1222 | - $s = $this->_UTF8toUTF16($s); |
|
| 1223 | - return '('.$this->_escape($s).')'; |
|
| 1220 | + // Format a text string |
|
| 1221 | + if(!$this->_isascii($s)) |
|
| 1222 | + $s = $this->_UTF8toUTF16($s); |
|
| 1223 | + return '('.$this->_escape($s).')'; |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | protected function _dounderline($x, $y, $txt) |
| 1227 | 1227 | { |
| 1228 | - // Underline text |
|
| 1229 | - $up = $this->CurrentFont['up']; |
|
| 1230 | - $ut = $this->CurrentFont['ut']; |
|
| 1231 | - $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); |
|
| 1232 | - 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); |
|
| 1228 | + // Underline text |
|
| 1229 | + $up = $this->CurrentFont['up']; |
|
| 1230 | + $ut = $this->CurrentFont['ut']; |
|
| 1231 | + $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); |
|
| 1232 | + 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); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | protected function _parsejpg($file) |
| 1236 | 1236 | { |
| 1237 | - // Extract info from a JPEG file |
|
| 1238 | - $a = getimagesize($file); |
|
| 1239 | - if(!$a) |
|
| 1240 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1241 | - if($a[2]!=2) |
|
| 1242 | - $this->Error('Not a JPEG file: '.$file); |
|
| 1243 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1244 | - $colspace = 'DeviceRGB'; |
|
| 1245 | - elseif($a['channels']==4) |
|
| 1246 | - $colspace = 'DeviceCMYK'; |
|
| 1247 | - else |
|
| 1248 | - $colspace = 'DeviceGray'; |
|
| 1249 | - $bpc = isset($a['bits']) ? $a['bits'] : 8; |
|
| 1250 | - $data = file_get_contents($file); |
|
| 1251 | - return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
|
| 1237 | + // Extract info from a JPEG file |
|
| 1238 | + $a = getimagesize($file); |
|
| 1239 | + if(!$a) |
|
| 1240 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1241 | + if($a[2]!=2) |
|
| 1242 | + $this->Error('Not a JPEG file: '.$file); |
|
| 1243 | + if(!isset($a['channels']) || $a['channels']==3) |
|
| 1244 | + $colspace = 'DeviceRGB'; |
|
| 1245 | + elseif($a['channels']==4) |
|
| 1246 | + $colspace = 'DeviceCMYK'; |
|
| 1247 | + else |
|
| 1248 | + $colspace = 'DeviceGray'; |
|
| 1249 | + $bpc = isset($a['bits']) ? $a['bits'] : 8; |
|
| 1250 | + $data = file_get_contents($file); |
|
| 1251 | + return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | protected function _parsepng($file) |
| 1255 | 1255 | { |
| 1256 | - // Extract info from a PNG file |
|
| 1257 | - $f = fopen($file,'rb'); |
|
| 1258 | - if(!$f) |
|
| 1259 | - $this->Error('Can\'t open image file: '.$file); |
|
| 1260 | - $info = $this->_parsepngstream($f,$file); |
|
| 1261 | - fclose($f); |
|
| 1262 | - return $info; |
|
| 1256 | + // Extract info from a PNG file |
|
| 1257 | + $f = fopen($file,'rb'); |
|
| 1258 | + if(!$f) |
|
| 1259 | + $this->Error('Can\'t open image file: '.$file); |
|
| 1260 | + $info = $this->_parsepngstream($f,$file); |
|
| 1261 | + fclose($f); |
|
| 1262 | + return $info; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | protected function _parsepngstream($f, $file) |
| 1266 | 1266 | { |
| 1267 | - // Check signature |
|
| 1268 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1269 | - $this->Error('Not a PNG file: '.$file); |
|
| 1270 | - |
|
| 1271 | - // Read header chunk |
|
| 1272 | - $this->_readstream($f,4); |
|
| 1273 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1274 | - $this->Error('Incorrect PNG file: '.$file); |
|
| 1275 | - $w = $this->_readint($f); |
|
| 1276 | - $h = $this->_readint($f); |
|
| 1277 | - $bpc = ord($this->_readstream($f,1)); |
|
| 1278 | - if($bpc>8) |
|
| 1279 | - $this->Error('16-bit depth not supported: '.$file); |
|
| 1280 | - $ct = ord($this->_readstream($f,1)); |
|
| 1281 | - if($ct==0 || $ct==4) |
|
| 1282 | - $colspace = 'DeviceGray'; |
|
| 1283 | - elseif($ct==2 || $ct==6) |
|
| 1284 | - $colspace = 'DeviceRGB'; |
|
| 1285 | - elseif($ct==3) |
|
| 1286 | - $colspace = 'Indexed'; |
|
| 1287 | - else |
|
| 1288 | - $this->Error('Unknown color type: '.$file); |
|
| 1289 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1290 | - $this->Error('Unknown compression method: '.$file); |
|
| 1291 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1292 | - $this->Error('Unknown filter method: '.$file); |
|
| 1293 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1294 | - $this->Error('Interlacing not supported: '.$file); |
|
| 1295 | - $this->_readstream($f,4); |
|
| 1296 | - $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
|
| 1297 | - |
|
| 1298 | - // Scan chunks looking for palette, transparency and image data |
|
| 1299 | - $pal = ''; |
|
| 1300 | - $trns = ''; |
|
| 1301 | - $data = ''; |
|
| 1302 | - do |
|
| 1303 | - { |
|
| 1304 | - $n = $this->_readint($f); |
|
| 1305 | - $type = $this->_readstream($f,4); |
|
| 1306 | - if($type=='PLTE') |
|
| 1307 | - { |
|
| 1308 | - // Read palette |
|
| 1309 | - $pal = $this->_readstream($f,$n); |
|
| 1310 | - $this->_readstream($f,4); |
|
| 1311 | - } |
|
| 1312 | - elseif($type=='tRNS') |
|
| 1313 | - { |
|
| 1314 | - // Read transparency info |
|
| 1315 | - $t = $this->_readstream($f,$n); |
|
| 1316 | - if($ct==0) |
|
| 1317 | - $trns = array(ord(substr($t,1,1))); |
|
| 1318 | - elseif($ct==2) |
|
| 1319 | - $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1320 | - else |
|
| 1321 | - { |
|
| 1322 | - $pos = strpos($t,chr(0)); |
|
| 1323 | - if($pos!==false) |
|
| 1324 | - $trns = array($pos); |
|
| 1325 | - } |
|
| 1326 | - $this->_readstream($f,4); |
|
| 1327 | - } |
|
| 1328 | - elseif($type=='IDAT') |
|
| 1329 | - { |
|
| 1330 | - // Read image data block |
|
| 1331 | - $data .= $this->_readstream($f,$n); |
|
| 1332 | - $this->_readstream($f,4); |
|
| 1333 | - } |
|
| 1334 | - elseif($type=='IEND') |
|
| 1335 | - break; |
|
| 1336 | - else |
|
| 1337 | - $this->_readstream($f,$n+4); |
|
| 1338 | - } |
|
| 1339 | - while($n); |
|
| 1340 | - |
|
| 1341 | - if($colspace=='Indexed' && empty($pal)) |
|
| 1342 | - $this->Error('Missing palette in '.$file); |
|
| 1343 | - $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); |
|
| 1344 | - if($ct>=4) |
|
| 1345 | - { |
|
| 1346 | - // Extract alpha channel |
|
| 1347 | - if(!function_exists('gzuncompress')) |
|
| 1348 | - $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
| 1349 | - $data = gzuncompress($data); |
|
| 1350 | - $color = ''; |
|
| 1351 | - $alpha = ''; |
|
| 1352 | - if($ct==4) |
|
| 1353 | - { |
|
| 1354 | - // Gray image |
|
| 1355 | - $len = 2*$w; |
|
| 1356 | - for($i=0;$i<$h;$i++) |
|
| 1357 | - { |
|
| 1358 | - $pos = (1+$len)*$i; |
|
| 1359 | - $color .= $data[$pos]; |
|
| 1360 | - $alpha .= $data[$pos]; |
|
| 1361 | - $line = substr($data,$pos+1,$len); |
|
| 1362 | - $color .= preg_replace('/(.)./s','$1',$line); |
|
| 1363 | - $alpha .= preg_replace('/.(.)/s','$1',$line); |
|
| 1364 | - } |
|
| 1365 | - } |
|
| 1366 | - else |
|
| 1367 | - { |
|
| 1368 | - // RGB image |
|
| 1369 | - $len = 4*$w; |
|
| 1370 | - for($i=0;$i<$h;$i++) |
|
| 1371 | - { |
|
| 1372 | - $pos = (1+$len)*$i; |
|
| 1373 | - $color .= $data[$pos]; |
|
| 1374 | - $alpha .= $data[$pos]; |
|
| 1375 | - $line = substr($data,$pos+1,$len); |
|
| 1376 | - $color .= preg_replace('/(.{3})./s','$1',$line); |
|
| 1377 | - $alpha .= preg_replace('/.{3}(.)/s','$1',$line); |
|
| 1378 | - } |
|
| 1379 | - } |
|
| 1380 | - unset($data); |
|
| 1381 | - $data = gzcompress($color); |
|
| 1382 | - $info['smask'] = gzcompress($alpha); |
|
| 1383 | - $this->WithAlpha = true; |
|
| 1384 | - if($this->PDFVersion<'1.4') |
|
| 1385 | - $this->PDFVersion = '1.4'; |
|
| 1386 | - } |
|
| 1387 | - $info['data'] = $data; |
|
| 1388 | - return $info; |
|
| 1267 | + // Check signature |
|
| 1268 | + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1269 | + $this->Error('Not a PNG file: '.$file); |
|
| 1270 | + |
|
| 1271 | + // Read header chunk |
|
| 1272 | + $this->_readstream($f,4); |
|
| 1273 | + if($this->_readstream($f,4)!='IHDR') |
|
| 1274 | + $this->Error('Incorrect PNG file: '.$file); |
|
| 1275 | + $w = $this->_readint($f); |
|
| 1276 | + $h = $this->_readint($f); |
|
| 1277 | + $bpc = ord($this->_readstream($f,1)); |
|
| 1278 | + if($bpc>8) |
|
| 1279 | + $this->Error('16-bit depth not supported: '.$file); |
|
| 1280 | + $ct = ord($this->_readstream($f,1)); |
|
| 1281 | + if($ct==0 || $ct==4) |
|
| 1282 | + $colspace = 'DeviceGray'; |
|
| 1283 | + elseif($ct==2 || $ct==6) |
|
| 1284 | + $colspace = 'DeviceRGB'; |
|
| 1285 | + elseif($ct==3) |
|
| 1286 | + $colspace = 'Indexed'; |
|
| 1287 | + else |
|
| 1288 | + $this->Error('Unknown color type: '.$file); |
|
| 1289 | + if(ord($this->_readstream($f,1))!=0) |
|
| 1290 | + $this->Error('Unknown compression method: '.$file); |
|
| 1291 | + if(ord($this->_readstream($f,1))!=0) |
|
| 1292 | + $this->Error('Unknown filter method: '.$file); |
|
| 1293 | + if(ord($this->_readstream($f,1))!=0) |
|
| 1294 | + $this->Error('Interlacing not supported: '.$file); |
|
| 1295 | + $this->_readstream($f,4); |
|
| 1296 | + $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
|
| 1297 | + |
|
| 1298 | + // Scan chunks looking for palette, transparency and image data |
|
| 1299 | + $pal = ''; |
|
| 1300 | + $trns = ''; |
|
| 1301 | + $data = ''; |
|
| 1302 | + do |
|
| 1303 | + { |
|
| 1304 | + $n = $this->_readint($f); |
|
| 1305 | + $type = $this->_readstream($f,4); |
|
| 1306 | + if($type=='PLTE') |
|
| 1307 | + { |
|
| 1308 | + // Read palette |
|
| 1309 | + $pal = $this->_readstream($f,$n); |
|
| 1310 | + $this->_readstream($f,4); |
|
| 1311 | + } |
|
| 1312 | + elseif($type=='tRNS') |
|
| 1313 | + { |
|
| 1314 | + // Read transparency info |
|
| 1315 | + $t = $this->_readstream($f,$n); |
|
| 1316 | + if($ct==0) |
|
| 1317 | + $trns = array(ord(substr($t,1,1))); |
|
| 1318 | + elseif($ct==2) |
|
| 1319 | + $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1320 | + else |
|
| 1321 | + { |
|
| 1322 | + $pos = strpos($t,chr(0)); |
|
| 1323 | + if($pos!==false) |
|
| 1324 | + $trns = array($pos); |
|
| 1325 | + } |
|
| 1326 | + $this->_readstream($f,4); |
|
| 1327 | + } |
|
| 1328 | + elseif($type=='IDAT') |
|
| 1329 | + { |
|
| 1330 | + // Read image data block |
|
| 1331 | + $data .= $this->_readstream($f,$n); |
|
| 1332 | + $this->_readstream($f,4); |
|
| 1333 | + } |
|
| 1334 | + elseif($type=='IEND') |
|
| 1335 | + break; |
|
| 1336 | + else |
|
| 1337 | + $this->_readstream($f,$n+4); |
|
| 1338 | + } |
|
| 1339 | + while($n); |
|
| 1340 | + |
|
| 1341 | + if($colspace=='Indexed' && empty($pal)) |
|
| 1342 | + $this->Error('Missing palette in '.$file); |
|
| 1343 | + $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); |
|
| 1344 | + if($ct>=4) |
|
| 1345 | + { |
|
| 1346 | + // Extract alpha channel |
|
| 1347 | + if(!function_exists('gzuncompress')) |
|
| 1348 | + $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
| 1349 | + $data = gzuncompress($data); |
|
| 1350 | + $color = ''; |
|
| 1351 | + $alpha = ''; |
|
| 1352 | + if($ct==4) |
|
| 1353 | + { |
|
| 1354 | + // Gray image |
|
| 1355 | + $len = 2*$w; |
|
| 1356 | + for($i=0;$i<$h;$i++) |
|
| 1357 | + { |
|
| 1358 | + $pos = (1+$len)*$i; |
|
| 1359 | + $color .= $data[$pos]; |
|
| 1360 | + $alpha .= $data[$pos]; |
|
| 1361 | + $line = substr($data,$pos+1,$len); |
|
| 1362 | + $color .= preg_replace('/(.)./s','$1',$line); |
|
| 1363 | + $alpha .= preg_replace('/.(.)/s','$1',$line); |
|
| 1364 | + } |
|
| 1365 | + } |
|
| 1366 | + else |
|
| 1367 | + { |
|
| 1368 | + // RGB image |
|
| 1369 | + $len = 4*$w; |
|
| 1370 | + for($i=0;$i<$h;$i++) |
|
| 1371 | + { |
|
| 1372 | + $pos = (1+$len)*$i; |
|
| 1373 | + $color .= $data[$pos]; |
|
| 1374 | + $alpha .= $data[$pos]; |
|
| 1375 | + $line = substr($data,$pos+1,$len); |
|
| 1376 | + $color .= preg_replace('/(.{3})./s','$1',$line); |
|
| 1377 | + $alpha .= preg_replace('/.{3}(.)/s','$1',$line); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1380 | + unset($data); |
|
| 1381 | + $data = gzcompress($color); |
|
| 1382 | + $info['smask'] = gzcompress($alpha); |
|
| 1383 | + $this->WithAlpha = true; |
|
| 1384 | + if($this->PDFVersion<'1.4') |
|
| 1385 | + $this->PDFVersion = '1.4'; |
|
| 1386 | + } |
|
| 1387 | + $info['data'] = $data; |
|
| 1388 | + return $info; |
|
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | 1391 | protected function _readstream($f, $n) |
| 1392 | 1392 | { |
| 1393 | - // Read n bytes from stream |
|
| 1394 | - $res = ''; |
|
| 1395 | - while($n>0 && !feof($f)) |
|
| 1396 | - { |
|
| 1397 | - $s = fread($f,$n); |
|
| 1398 | - if($s===false) |
|
| 1399 | - $this->Error('Error while reading stream'); |
|
| 1400 | - $n -= strlen($s); |
|
| 1401 | - $res .= $s; |
|
| 1402 | - } |
|
| 1403 | - if($n>0) |
|
| 1404 | - $this->Error('Unexpected end of stream'); |
|
| 1405 | - return $res; |
|
| 1393 | + // Read n bytes from stream |
|
| 1394 | + $res = ''; |
|
| 1395 | + while($n>0 && !feof($f)) |
|
| 1396 | + { |
|
| 1397 | + $s = fread($f,$n); |
|
| 1398 | + if($s===false) |
|
| 1399 | + $this->Error('Error while reading stream'); |
|
| 1400 | + $n -= strlen($s); |
|
| 1401 | + $res .= $s; |
|
| 1402 | + } |
|
| 1403 | + if($n>0) |
|
| 1404 | + $this->Error('Unexpected end of stream'); |
|
| 1405 | + return $res; |
|
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | 1408 | protected function _readint($f) |
| 1409 | 1409 | { |
| 1410 | - // Read a 4-byte integer from stream |
|
| 1411 | - $a = unpack('Ni',$this->_readstream($f,4)); |
|
| 1412 | - return $a['i']; |
|
| 1410 | + // Read a 4-byte integer from stream |
|
| 1411 | + $a = unpack('Ni',$this->_readstream($f,4)); |
|
| 1412 | + return $a['i']; |
|
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | 1415 | protected function _parsegif($file) |
| 1416 | 1416 | { |
| 1417 | - // Extract info from a GIF file (via PNG conversion) |
|
| 1418 | - if(!function_exists('imagepng')) |
|
| 1419 | - $this->Error('GD extension is required for GIF support'); |
|
| 1420 | - if(!function_exists('imagecreatefromgif')) |
|
| 1421 | - $this->Error('GD has no GIF read support'); |
|
| 1422 | - $im = imagecreatefromgif($file); |
|
| 1423 | - if(!$im) |
|
| 1424 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1425 | - imageinterlace($im,0); |
|
| 1426 | - ob_start(); |
|
| 1427 | - imagepng($im); |
|
| 1428 | - $data = ob_get_clean(); |
|
| 1429 | - imagedestroy($im); |
|
| 1430 | - $f = fopen('php://temp','rb+'); |
|
| 1431 | - if(!$f) |
|
| 1432 | - $this->Error('Unable to create memory stream'); |
|
| 1433 | - fwrite($f,$data); |
|
| 1434 | - rewind($f); |
|
| 1435 | - $info = $this->_parsepngstream($f,$file); |
|
| 1436 | - fclose($f); |
|
| 1437 | - return $info; |
|
| 1417 | + // Extract info from a GIF file (via PNG conversion) |
|
| 1418 | + if(!function_exists('imagepng')) |
|
| 1419 | + $this->Error('GD extension is required for GIF support'); |
|
| 1420 | + if(!function_exists('imagecreatefromgif')) |
|
| 1421 | + $this->Error('GD has no GIF read support'); |
|
| 1422 | + $im = imagecreatefromgif($file); |
|
| 1423 | + if(!$im) |
|
| 1424 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1425 | + imageinterlace($im,0); |
|
| 1426 | + ob_start(); |
|
| 1427 | + imagepng($im); |
|
| 1428 | + $data = ob_get_clean(); |
|
| 1429 | + imagedestroy($im); |
|
| 1430 | + $f = fopen('php://temp','rb+'); |
|
| 1431 | + if(!$f) |
|
| 1432 | + $this->Error('Unable to create memory stream'); |
|
| 1433 | + fwrite($f,$data); |
|
| 1434 | + rewind($f); |
|
| 1435 | + $info = $this->_parsepngstream($f,$file); |
|
| 1436 | + fclose($f); |
|
| 1437 | + return $info; |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | protected function _out($s) |
| 1441 | 1441 | { |
| 1442 | - // Add a line to the document |
|
| 1443 | - if($this->state==2) |
|
| 1444 | - $this->pages[$this->page] .= $s."\n"; |
|
| 1445 | - elseif($this->state==1) |
|
| 1446 | - $this->_put($s); |
|
| 1447 | - elseif($this->state==0) |
|
| 1448 | - $this->Error('No page has been added yet'); |
|
| 1449 | - elseif($this->state==3) |
|
| 1450 | - $this->Error('The document is closed'); |
|
| 1442 | + // Add a line to the document |
|
| 1443 | + if($this->state==2) |
|
| 1444 | + $this->pages[$this->page] .= $s."\n"; |
|
| 1445 | + elseif($this->state==1) |
|
| 1446 | + $this->_put($s); |
|
| 1447 | + elseif($this->state==0) |
|
| 1448 | + $this->Error('No page has been added yet'); |
|
| 1449 | + elseif($this->state==3) |
|
| 1450 | + $this->Error('The document is closed'); |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | protected function _put($s) |
| 1454 | 1454 | { |
| 1455 | - $this->buffer .= $s."\n"; |
|
| 1455 | + $this->buffer .= $s."\n"; |
|
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | 1458 | protected function _getoffset() |
| 1459 | 1459 | { |
| 1460 | - return strlen($this->buffer); |
|
| 1460 | + return strlen($this->buffer); |
|
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | 1463 | protected function _newobj($n=null) |
| 1464 | 1464 | { |
| 1465 | - // Begin a new object |
|
| 1466 | - if($n===null) |
|
| 1467 | - $n = ++$this->n; |
|
| 1468 | - $this->offsets[$n] = $this->_getoffset(); |
|
| 1469 | - $this->_put($n.' 0 obj'); |
|
| 1465 | + // Begin a new object |
|
| 1466 | + if($n===null) |
|
| 1467 | + $n = ++$this->n; |
|
| 1468 | + $this->offsets[$n] = $this->_getoffset(); |
|
| 1469 | + $this->_put($n.' 0 obj'); |
|
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | protected function _putstream($data) |
| 1473 | 1473 | { |
| 1474 | - $this->_put('stream'); |
|
| 1475 | - $this->_put($data); |
|
| 1476 | - $this->_put('endstream'); |
|
| 1474 | + $this->_put('stream'); |
|
| 1475 | + $this->_put($data); |
|
| 1476 | + $this->_put('endstream'); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | protected function _putstreamobject($data) |
| 1480 | 1480 | { |
| 1481 | - if($this->compress) |
|
| 1482 | - { |
|
| 1483 | - $entries = '/Filter /FlateDecode '; |
|
| 1484 | - $data = gzcompress($data); |
|
| 1485 | - } |
|
| 1486 | - else |
|
| 1487 | - $entries = ''; |
|
| 1488 | - $entries .= '/Length '.strlen($data); |
|
| 1489 | - $this->_newobj(); |
|
| 1490 | - $this->_put('<<'.$entries.'>>'); |
|
| 1491 | - $this->_putstream($data); |
|
| 1492 | - $this->_put('endobj'); |
|
| 1481 | + if($this->compress) |
|
| 1482 | + { |
|
| 1483 | + $entries = '/Filter /FlateDecode '; |
|
| 1484 | + $data = gzcompress($data); |
|
| 1485 | + } |
|
| 1486 | + else |
|
| 1487 | + $entries = ''; |
|
| 1488 | + $entries .= '/Length '.strlen($data); |
|
| 1489 | + $this->_newobj(); |
|
| 1490 | + $this->_put('<<'.$entries.'>>'); |
|
| 1491 | + $this->_putstream($data); |
|
| 1492 | + $this->_put('endobj'); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | 1495 | protected function _putpage($n) |
| 1496 | 1496 | { |
| 1497 | - $this->_newobj(); |
|
| 1498 | - $this->_put('<</Type /Page'); |
|
| 1499 | - $this->_put('/Parent 1 0 R'); |
|
| 1500 | - if(isset($this->PageInfo[$n]['size'])) |
|
| 1501 | - $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); |
|
| 1502 | - if(isset($this->PageInfo[$n]['rotation'])) |
|
| 1503 | - $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); |
|
| 1504 | - $this->_put('/Resources 2 0 R'); |
|
| 1505 | - if(!empty($this->PageLinks[$n])) |
|
| 1506 | - { |
|
| 1507 | - $s = '/Annots ['; |
|
| 1508 | - foreach($this->PageLinks[$n] as $pl) |
|
| 1509 | - $s .= $pl[5].' 0 R '; |
|
| 1510 | - $s .= ']'; |
|
| 1511 | - $this->_put($s); |
|
| 1512 | - } |
|
| 1513 | - if($this->WithAlpha) |
|
| 1514 | - $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
| 1515 | - $this->_put('/Contents '.($this->n+1).' 0 R>>'); |
|
| 1516 | - $this->_put('endobj'); |
|
| 1517 | - // Page content |
|
| 1518 | - if(!empty($this->AliasNbPages)) |
|
| 1519 | - $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); |
|
| 1520 | - $this->_putstreamobject($this->pages[$n]); |
|
| 1521 | - // Annotations |
|
| 1522 | - foreach($this->PageLinks[$n] as $pl) |
|
| 1523 | - { |
|
| 1524 | - $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
|
| 1525 | - $s = '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
|
| 1526 | - if(is_string($pl[4])) |
|
| 1527 | - $s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1528 | - else |
|
| 1529 | - { |
|
| 1530 | - $l = $this->links[$pl[4]]; |
|
| 1531 | - if(isset($this->PageInfo[$l[0]]['size'])) |
|
| 1532 | - $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 1533 | - else |
|
| 1534 | - $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 1535 | - $s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); |
|
| 1536 | - } |
|
| 1537 | - $this->_newobj(); |
|
| 1538 | - $this->_put($s); |
|
| 1539 | - $this->_put('endobj'); |
|
| 1540 | - } |
|
| 1497 | + $this->_newobj(); |
|
| 1498 | + $this->_put('<</Type /Page'); |
|
| 1499 | + $this->_put('/Parent 1 0 R'); |
|
| 1500 | + if(isset($this->PageInfo[$n]['size'])) |
|
| 1501 | + $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); |
|
| 1502 | + if(isset($this->PageInfo[$n]['rotation'])) |
|
| 1503 | + $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); |
|
| 1504 | + $this->_put('/Resources 2 0 R'); |
|
| 1505 | + if(!empty($this->PageLinks[$n])) |
|
| 1506 | + { |
|
| 1507 | + $s = '/Annots ['; |
|
| 1508 | + foreach($this->PageLinks[$n] as $pl) |
|
| 1509 | + $s .= $pl[5].' 0 R '; |
|
| 1510 | + $s .= ']'; |
|
| 1511 | + $this->_put($s); |
|
| 1512 | + } |
|
| 1513 | + if($this->WithAlpha) |
|
| 1514 | + $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
| 1515 | + $this->_put('/Contents '.($this->n+1).' 0 R>>'); |
|
| 1516 | + $this->_put('endobj'); |
|
| 1517 | + // Page content |
|
| 1518 | + if(!empty($this->AliasNbPages)) |
|
| 1519 | + $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); |
|
| 1520 | + $this->_putstreamobject($this->pages[$n]); |
|
| 1521 | + // Annotations |
|
| 1522 | + foreach($this->PageLinks[$n] as $pl) |
|
| 1523 | + { |
|
| 1524 | + $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
|
| 1525 | + $s = '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
|
| 1526 | + if(is_string($pl[4])) |
|
| 1527 | + $s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1528 | + else |
|
| 1529 | + { |
|
| 1530 | + $l = $this->links[$pl[4]]; |
|
| 1531 | + if(isset($this->PageInfo[$l[0]]['size'])) |
|
| 1532 | + $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 1533 | + else |
|
| 1534 | + $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 1535 | + $s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); |
|
| 1536 | + } |
|
| 1537 | + $this->_newobj(); |
|
| 1538 | + $this->_put($s); |
|
| 1539 | + $this->_put('endobj'); |
|
| 1540 | + } |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | protected function _putpages() |
| 1544 | 1544 | { |
| 1545 | - $nb = $this->page; |
|
| 1546 | - $n = $this->n; |
|
| 1547 | - for($i=1;$i<=$nb;$i++) |
|
| 1548 | - { |
|
| 1549 | - $this->PageInfo[$i]['n'] = ++$n; |
|
| 1550 | - $n++; |
|
| 1551 | - foreach($this->PageLinks[$i] as &$pl) |
|
| 1552 | - $pl[5] = ++$n; |
|
| 1553 | - unset($pl); |
|
| 1554 | - } |
|
| 1555 | - for($i=1;$i<=$nb;$i++) |
|
| 1556 | - $this->_putpage($i); |
|
| 1557 | - // Pages root |
|
| 1558 | - $this->_newobj(1); |
|
| 1559 | - $this->_put('<</Type /Pages'); |
|
| 1560 | - $kids = '/Kids ['; |
|
| 1561 | - for($i=1;$i<=$nb;$i++) |
|
| 1562 | - $kids .= $this->PageInfo[$i]['n'].' 0 R '; |
|
| 1563 | - $kids .= ']'; |
|
| 1564 | - $this->_put($kids); |
|
| 1565 | - $this->_put('/Count '.$nb); |
|
| 1566 | - if($this->DefOrientation=='P') |
|
| 1567 | - { |
|
| 1568 | - $w = $this->DefPageSize[0]; |
|
| 1569 | - $h = $this->DefPageSize[1]; |
|
| 1570 | - } |
|
| 1571 | - else |
|
| 1572 | - { |
|
| 1573 | - $w = $this->DefPageSize[1]; |
|
| 1574 | - $h = $this->DefPageSize[0]; |
|
| 1575 | - } |
|
| 1576 | - $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$w*$this->k,$h*$this->k)); |
|
| 1577 | - $this->_put('>>'); |
|
| 1578 | - $this->_put('endobj'); |
|
| 1545 | + $nb = $this->page; |
|
| 1546 | + $n = $this->n; |
|
| 1547 | + for($i=1;$i<=$nb;$i++) |
|
| 1548 | + { |
|
| 1549 | + $this->PageInfo[$i]['n'] = ++$n; |
|
| 1550 | + $n++; |
|
| 1551 | + foreach($this->PageLinks[$i] as &$pl) |
|
| 1552 | + $pl[5] = ++$n; |
|
| 1553 | + unset($pl); |
|
| 1554 | + } |
|
| 1555 | + for($i=1;$i<=$nb;$i++) |
|
| 1556 | + $this->_putpage($i); |
|
| 1557 | + // Pages root |
|
| 1558 | + $this->_newobj(1); |
|
| 1559 | + $this->_put('<</Type /Pages'); |
|
| 1560 | + $kids = '/Kids ['; |
|
| 1561 | + for($i=1;$i<=$nb;$i++) |
|
| 1562 | + $kids .= $this->PageInfo[$i]['n'].' 0 R '; |
|
| 1563 | + $kids .= ']'; |
|
| 1564 | + $this->_put($kids); |
|
| 1565 | + $this->_put('/Count '.$nb); |
|
| 1566 | + if($this->DefOrientation=='P') |
|
| 1567 | + { |
|
| 1568 | + $w = $this->DefPageSize[0]; |
|
| 1569 | + $h = $this->DefPageSize[1]; |
|
| 1570 | + } |
|
| 1571 | + else |
|
| 1572 | + { |
|
| 1573 | + $w = $this->DefPageSize[1]; |
|
| 1574 | + $h = $this->DefPageSize[0]; |
|
| 1575 | + } |
|
| 1576 | + $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$w*$this->k,$h*$this->k)); |
|
| 1577 | + $this->_put('>>'); |
|
| 1578 | + $this->_put('endobj'); |
|
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | protected function _putfonts() |
| 1582 | 1582 | { |
| 1583 | - foreach($this->FontFiles as $file=>$info) |
|
| 1584 | - { |
|
| 1585 | - // Font file embedding |
|
| 1586 | - $this->_newobj(); |
|
| 1587 | - $this->FontFiles[$file]['n'] = $this->n; |
|
| 1588 | - $font = file_get_contents($this->fontpath.$file,true); |
|
| 1589 | - if(!$font) |
|
| 1590 | - $this->Error('Font file not found: '.$file); |
|
| 1591 | - $compressed = (substr($file,-2)=='.z'); |
|
| 1592 | - if(!$compressed && isset($info['length2'])) |
|
| 1593 | - $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); |
|
| 1594 | - $this->_put('<</Length '.strlen($font)); |
|
| 1595 | - if($compressed) |
|
| 1596 | - $this->_put('/Filter /FlateDecode'); |
|
| 1597 | - $this->_put('/Length1 '.$info['length1']); |
|
| 1598 | - if(isset($info['length2'])) |
|
| 1599 | - $this->_put('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1600 | - $this->_put('>>'); |
|
| 1601 | - $this->_putstream($font); |
|
| 1602 | - $this->_put('endobj'); |
|
| 1603 | - } |
|
| 1604 | - foreach($this->fonts as $k=>$font) |
|
| 1605 | - { |
|
| 1606 | - // Encoding |
|
| 1607 | - if(isset($font['diff'])) |
|
| 1608 | - { |
|
| 1609 | - if(!isset($this->encodings[$font['enc']])) |
|
| 1610 | - { |
|
| 1611 | - $this->_newobj(); |
|
| 1612 | - $this->_put('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$font['diff'].']>>'); |
|
| 1613 | - $this->_put('endobj'); |
|
| 1614 | - $this->encodings[$font['enc']] = $this->n; |
|
| 1615 | - } |
|
| 1616 | - } |
|
| 1617 | - // ToUnicode CMap |
|
| 1618 | - if(isset($font['uv'])) |
|
| 1619 | - { |
|
| 1620 | - if(isset($font['enc'])) |
|
| 1621 | - $cmapkey = $font['enc']; |
|
| 1622 | - else |
|
| 1623 | - $cmapkey = $font['name']; |
|
| 1624 | - if(!isset($this->cmaps[$cmapkey])) |
|
| 1625 | - { |
|
| 1626 | - $cmap = $this->_tounicodecmap($font['uv']); |
|
| 1627 | - $this->_putstreamobject($cmap); |
|
| 1628 | - $this->cmaps[$cmapkey] = $this->n; |
|
| 1629 | - } |
|
| 1630 | - } |
|
| 1631 | - // Font object |
|
| 1632 | - $this->fonts[$k]['n'] = $this->n+1; |
|
| 1633 | - $type = $font['type']; |
|
| 1634 | - $name = $font['name']; |
|
| 1635 | - if($font['subsetted']) |
|
| 1636 | - $name = 'AAAAAA+'.$name; |
|
| 1637 | - if($type=='Core') |
|
| 1638 | - { |
|
| 1639 | - // Core font |
|
| 1640 | - $this->_newobj(); |
|
| 1641 | - $this->_put('<</Type /Font'); |
|
| 1642 | - $this->_put('/BaseFont /'.$name); |
|
| 1643 | - $this->_put('/Subtype /Type1'); |
|
| 1644 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1645 | - $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1646 | - if(isset($font['uv'])) |
|
| 1647 | - $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1648 | - $this->_put('>>'); |
|
| 1649 | - $this->_put('endobj'); |
|
| 1650 | - } |
|
| 1651 | - elseif($type=='Type1' || $type=='TrueType') |
|
| 1652 | - { |
|
| 1653 | - // Additional Type1 or TrueType/OpenType font |
|
| 1654 | - $this->_newobj(); |
|
| 1655 | - $this->_put('<</Type /Font'); |
|
| 1656 | - $this->_put('/BaseFont /'.$name); |
|
| 1657 | - $this->_put('/Subtype /'.$type); |
|
| 1658 | - $this->_put('/FirstChar 32 /LastChar 255'); |
|
| 1659 | - $this->_put('/Widths '.($this->n+1).' 0 R'); |
|
| 1660 | - $this->_put('/FontDescriptor '.($this->n+2).' 0 R'); |
|
| 1661 | - if(isset($font['diff'])) |
|
| 1662 | - $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); |
|
| 1663 | - else |
|
| 1664 | - $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1665 | - if(isset($font['uv'])) |
|
| 1666 | - $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1667 | - $this->_put('>>'); |
|
| 1668 | - $this->_put('endobj'); |
|
| 1669 | - // Widths |
|
| 1670 | - $this->_newobj(); |
|
| 1671 | - $cw = &$font['cw']; |
|
| 1672 | - $s = '['; |
|
| 1673 | - for($i=32;$i<=255;$i++) |
|
| 1674 | - $s .= $cw[chr($i)].' '; |
|
| 1675 | - $this->_put($s.']'); |
|
| 1676 | - $this->_put('endobj'); |
|
| 1677 | - // Descriptor |
|
| 1678 | - $this->_newobj(); |
|
| 1679 | - $s = '<</Type /FontDescriptor /FontName /'.$name; |
|
| 1680 | - foreach($font['desc'] as $k=>$v) |
|
| 1681 | - $s .= ' /'.$k.' '.$v; |
|
| 1682 | - if(!empty($font['file'])) |
|
| 1683 | - $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1684 | - $this->_put($s.'>>'); |
|
| 1685 | - $this->_put('endobj'); |
|
| 1686 | - } |
|
| 1687 | - else |
|
| 1688 | - { |
|
| 1689 | - // Allow for additional types |
|
| 1690 | - $mtd = '_put'.strtolower($type); |
|
| 1691 | - if(!method_exists($this,$mtd)) |
|
| 1692 | - $this->Error('Unsupported font type: '.$type); |
|
| 1693 | - $this->$mtd($font); |
|
| 1694 | - } |
|
| 1695 | - } |
|
| 1583 | + foreach($this->FontFiles as $file=>$info) |
|
| 1584 | + { |
|
| 1585 | + // Font file embedding |
|
| 1586 | + $this->_newobj(); |
|
| 1587 | + $this->FontFiles[$file]['n'] = $this->n; |
|
| 1588 | + $font = file_get_contents($this->fontpath.$file,true); |
|
| 1589 | + if(!$font) |
|
| 1590 | + $this->Error('Font file not found: '.$file); |
|
| 1591 | + $compressed = (substr($file,-2)=='.z'); |
|
| 1592 | + if(!$compressed && isset($info['length2'])) |
|
| 1593 | + $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); |
|
| 1594 | + $this->_put('<</Length '.strlen($font)); |
|
| 1595 | + if($compressed) |
|
| 1596 | + $this->_put('/Filter /FlateDecode'); |
|
| 1597 | + $this->_put('/Length1 '.$info['length1']); |
|
| 1598 | + if(isset($info['length2'])) |
|
| 1599 | + $this->_put('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1600 | + $this->_put('>>'); |
|
| 1601 | + $this->_putstream($font); |
|
| 1602 | + $this->_put('endobj'); |
|
| 1603 | + } |
|
| 1604 | + foreach($this->fonts as $k=>$font) |
|
| 1605 | + { |
|
| 1606 | + // Encoding |
|
| 1607 | + if(isset($font['diff'])) |
|
| 1608 | + { |
|
| 1609 | + if(!isset($this->encodings[$font['enc']])) |
|
| 1610 | + { |
|
| 1611 | + $this->_newobj(); |
|
| 1612 | + $this->_put('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$font['diff'].']>>'); |
|
| 1613 | + $this->_put('endobj'); |
|
| 1614 | + $this->encodings[$font['enc']] = $this->n; |
|
| 1615 | + } |
|
| 1616 | + } |
|
| 1617 | + // ToUnicode CMap |
|
| 1618 | + if(isset($font['uv'])) |
|
| 1619 | + { |
|
| 1620 | + if(isset($font['enc'])) |
|
| 1621 | + $cmapkey = $font['enc']; |
|
| 1622 | + else |
|
| 1623 | + $cmapkey = $font['name']; |
|
| 1624 | + if(!isset($this->cmaps[$cmapkey])) |
|
| 1625 | + { |
|
| 1626 | + $cmap = $this->_tounicodecmap($font['uv']); |
|
| 1627 | + $this->_putstreamobject($cmap); |
|
| 1628 | + $this->cmaps[$cmapkey] = $this->n; |
|
| 1629 | + } |
|
| 1630 | + } |
|
| 1631 | + // Font object |
|
| 1632 | + $this->fonts[$k]['n'] = $this->n+1; |
|
| 1633 | + $type = $font['type']; |
|
| 1634 | + $name = $font['name']; |
|
| 1635 | + if($font['subsetted']) |
|
| 1636 | + $name = 'AAAAAA+'.$name; |
|
| 1637 | + if($type=='Core') |
|
| 1638 | + { |
|
| 1639 | + // Core font |
|
| 1640 | + $this->_newobj(); |
|
| 1641 | + $this->_put('<</Type /Font'); |
|
| 1642 | + $this->_put('/BaseFont /'.$name); |
|
| 1643 | + $this->_put('/Subtype /Type1'); |
|
| 1644 | + if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1645 | + $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1646 | + if(isset($font['uv'])) |
|
| 1647 | + $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1648 | + $this->_put('>>'); |
|
| 1649 | + $this->_put('endobj'); |
|
| 1650 | + } |
|
| 1651 | + elseif($type=='Type1' || $type=='TrueType') |
|
| 1652 | + { |
|
| 1653 | + // Additional Type1 or TrueType/OpenType font |
|
| 1654 | + $this->_newobj(); |
|
| 1655 | + $this->_put('<</Type /Font'); |
|
| 1656 | + $this->_put('/BaseFont /'.$name); |
|
| 1657 | + $this->_put('/Subtype /'.$type); |
|
| 1658 | + $this->_put('/FirstChar 32 /LastChar 255'); |
|
| 1659 | + $this->_put('/Widths '.($this->n+1).' 0 R'); |
|
| 1660 | + $this->_put('/FontDescriptor '.($this->n+2).' 0 R'); |
|
| 1661 | + if(isset($font['diff'])) |
|
| 1662 | + $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); |
|
| 1663 | + else |
|
| 1664 | + $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1665 | + if(isset($font['uv'])) |
|
| 1666 | + $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1667 | + $this->_put('>>'); |
|
| 1668 | + $this->_put('endobj'); |
|
| 1669 | + // Widths |
|
| 1670 | + $this->_newobj(); |
|
| 1671 | + $cw = &$font['cw']; |
|
| 1672 | + $s = '['; |
|
| 1673 | + for($i=32;$i<=255;$i++) |
|
| 1674 | + $s .= $cw[chr($i)].' '; |
|
| 1675 | + $this->_put($s.']'); |
|
| 1676 | + $this->_put('endobj'); |
|
| 1677 | + // Descriptor |
|
| 1678 | + $this->_newobj(); |
|
| 1679 | + $s = '<</Type /FontDescriptor /FontName /'.$name; |
|
| 1680 | + foreach($font['desc'] as $k=>$v) |
|
| 1681 | + $s .= ' /'.$k.' '.$v; |
|
| 1682 | + if(!empty($font['file'])) |
|
| 1683 | + $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1684 | + $this->_put($s.'>>'); |
|
| 1685 | + $this->_put('endobj'); |
|
| 1686 | + } |
|
| 1687 | + else |
|
| 1688 | + { |
|
| 1689 | + // Allow for additional types |
|
| 1690 | + $mtd = '_put'.strtolower($type); |
|
| 1691 | + if(!method_exists($this,$mtd)) |
|
| 1692 | + $this->Error('Unsupported font type: '.$type); |
|
| 1693 | + $this->$mtd($font); |
|
| 1694 | + } |
|
| 1695 | + } |
|
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | 1698 | protected function _tounicodecmap($uv) |
| 1699 | 1699 | { |
| 1700 | - $ranges = ''; |
|
| 1701 | - $nbr = 0; |
|
| 1702 | - $chars = ''; |
|
| 1703 | - $nbc = 0; |
|
| 1704 | - foreach($uv as $c=>$v) |
|
| 1705 | - { |
|
| 1706 | - if(is_array($v)) |
|
| 1707 | - { |
|
| 1708 | - $ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]); |
|
| 1709 | - $nbr++; |
|
| 1710 | - } |
|
| 1711 | - else |
|
| 1712 | - { |
|
| 1713 | - $chars .= sprintf("<%02X> <%04X>\n",$c,$v); |
|
| 1714 | - $nbc++; |
|
| 1715 | - } |
|
| 1716 | - } |
|
| 1717 | - $s = "/CIDInit /ProcSet findresource begin\n"; |
|
| 1718 | - $s .= "12 dict begin\n"; |
|
| 1719 | - $s .= "begincmap\n"; |
|
| 1720 | - $s .= "/CIDSystemInfo\n"; |
|
| 1721 | - $s .= "<</Registry (Adobe)\n"; |
|
| 1722 | - $s .= "/Ordering (UCS)\n"; |
|
| 1723 | - $s .= "/Supplement 0\n"; |
|
| 1724 | - $s .= ">> def\n"; |
|
| 1725 | - $s .= "/CMapName /Adobe-Identity-UCS def\n"; |
|
| 1726 | - $s .= "/CMapType 2 def\n"; |
|
| 1727 | - $s .= "1 begincodespacerange\n"; |
|
| 1728 | - $s .= "<00> <FF>\n"; |
|
| 1729 | - $s .= "endcodespacerange\n"; |
|
| 1730 | - if($nbr>0) |
|
| 1731 | - { |
|
| 1732 | - $s .= "$nbr beginbfrange\n"; |
|
| 1733 | - $s .= $ranges; |
|
| 1734 | - $s .= "endbfrange\n"; |
|
| 1735 | - } |
|
| 1736 | - if($nbc>0) |
|
| 1737 | - { |
|
| 1738 | - $s .= "$nbc beginbfchar\n"; |
|
| 1739 | - $s .= $chars; |
|
| 1740 | - $s .= "endbfchar\n"; |
|
| 1741 | - } |
|
| 1742 | - $s .= "endcmap\n"; |
|
| 1743 | - $s .= "CMapName currentdict /CMap defineresource pop\n"; |
|
| 1744 | - $s .= "end\n"; |
|
| 1745 | - $s .= "end"; |
|
| 1746 | - return $s; |
|
| 1700 | + $ranges = ''; |
|
| 1701 | + $nbr = 0; |
|
| 1702 | + $chars = ''; |
|
| 1703 | + $nbc = 0; |
|
| 1704 | + foreach($uv as $c=>$v) |
|
| 1705 | + { |
|
| 1706 | + if(is_array($v)) |
|
| 1707 | + { |
|
| 1708 | + $ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]); |
|
| 1709 | + $nbr++; |
|
| 1710 | + } |
|
| 1711 | + else |
|
| 1712 | + { |
|
| 1713 | + $chars .= sprintf("<%02X> <%04X>\n",$c,$v); |
|
| 1714 | + $nbc++; |
|
| 1715 | + } |
|
| 1716 | + } |
|
| 1717 | + $s = "/CIDInit /ProcSet findresource begin\n"; |
|
| 1718 | + $s .= "12 dict begin\n"; |
|
| 1719 | + $s .= "begincmap\n"; |
|
| 1720 | + $s .= "/CIDSystemInfo\n"; |
|
| 1721 | + $s .= "<</Registry (Adobe)\n"; |
|
| 1722 | + $s .= "/Ordering (UCS)\n"; |
|
| 1723 | + $s .= "/Supplement 0\n"; |
|
| 1724 | + $s .= ">> def\n"; |
|
| 1725 | + $s .= "/CMapName /Adobe-Identity-UCS def\n"; |
|
| 1726 | + $s .= "/CMapType 2 def\n"; |
|
| 1727 | + $s .= "1 begincodespacerange\n"; |
|
| 1728 | + $s .= "<00> <FF>\n"; |
|
| 1729 | + $s .= "endcodespacerange\n"; |
|
| 1730 | + if($nbr>0) |
|
| 1731 | + { |
|
| 1732 | + $s .= "$nbr beginbfrange\n"; |
|
| 1733 | + $s .= $ranges; |
|
| 1734 | + $s .= "endbfrange\n"; |
|
| 1735 | + } |
|
| 1736 | + if($nbc>0) |
|
| 1737 | + { |
|
| 1738 | + $s .= "$nbc beginbfchar\n"; |
|
| 1739 | + $s .= $chars; |
|
| 1740 | + $s .= "endbfchar\n"; |
|
| 1741 | + } |
|
| 1742 | + $s .= "endcmap\n"; |
|
| 1743 | + $s .= "CMapName currentdict /CMap defineresource pop\n"; |
|
| 1744 | + $s .= "end\n"; |
|
| 1745 | + $s .= "end"; |
|
| 1746 | + return $s; |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | protected function _putimages() |
| 1750 | 1750 | { |
| 1751 | - foreach(array_keys($this->images) as $file) |
|
| 1752 | - { |
|
| 1753 | - $this->_putimage($this->images[$file]); |
|
| 1754 | - unset($this->images[$file]['data']); |
|
| 1755 | - unset($this->images[$file]['smask']); |
|
| 1756 | - } |
|
| 1751 | + foreach(array_keys($this->images) as $file) |
|
| 1752 | + { |
|
| 1753 | + $this->_putimage($this->images[$file]); |
|
| 1754 | + unset($this->images[$file]['data']); |
|
| 1755 | + unset($this->images[$file]['smask']); |
|
| 1756 | + } |
|
| 1757 | 1757 | } |
| 1758 | 1758 | |
| 1759 | 1759 | protected function _putimage(&$info) |
| 1760 | 1760 | { |
| 1761 | - $this->_newobj(); |
|
| 1762 | - $info['n'] = $this->n; |
|
| 1763 | - $this->_put('<</Type /XObject'); |
|
| 1764 | - $this->_put('/Subtype /Image'); |
|
| 1765 | - $this->_put('/Width '.$info['w']); |
|
| 1766 | - $this->_put('/Height '.$info['h']); |
|
| 1767 | - if($info['cs']=='Indexed') |
|
| 1768 | - $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1769 | - else |
|
| 1770 | - { |
|
| 1771 | - $this->_put('/ColorSpace /'.$info['cs']); |
|
| 1772 | - if($info['cs']=='DeviceCMYK') |
|
| 1773 | - $this->_put('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1774 | - } |
|
| 1775 | - $this->_put('/BitsPerComponent '.$info['bpc']); |
|
| 1776 | - if(isset($info['f'])) |
|
| 1777 | - $this->_put('/Filter /'.$info['f']); |
|
| 1778 | - if(isset($info['dp'])) |
|
| 1779 | - $this->_put('/DecodeParms <<'.$info['dp'].'>>'); |
|
| 1780 | - if(isset($info['trns']) && is_array($info['trns'])) |
|
| 1781 | - { |
|
| 1782 | - $trns = ''; |
|
| 1783 | - for($i=0;$i<count($info['trns']);$i++) |
|
| 1784 | - $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1785 | - $this->_put('/Mask ['.$trns.']'); |
|
| 1786 | - } |
|
| 1787 | - if(isset($info['smask'])) |
|
| 1788 | - $this->_put('/SMask '.($this->n+1).' 0 R'); |
|
| 1789 | - $this->_put('/Length '.strlen($info['data']).'>>'); |
|
| 1790 | - $this->_putstream($info['data']); |
|
| 1791 | - $this->_put('endobj'); |
|
| 1792 | - // Soft mask |
|
| 1793 | - if(isset($info['smask'])) |
|
| 1794 | - { |
|
| 1795 | - $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w']; |
|
| 1796 | - $smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']); |
|
| 1797 | - $this->_putimage($smask); |
|
| 1798 | - } |
|
| 1799 | - // Palette |
|
| 1800 | - if($info['cs']=='Indexed') |
|
| 1801 | - $this->_putstreamobject($info['pal']); |
|
| 1761 | + $this->_newobj(); |
|
| 1762 | + $info['n'] = $this->n; |
|
| 1763 | + $this->_put('<</Type /XObject'); |
|
| 1764 | + $this->_put('/Subtype /Image'); |
|
| 1765 | + $this->_put('/Width '.$info['w']); |
|
| 1766 | + $this->_put('/Height '.$info['h']); |
|
| 1767 | + if($info['cs']=='Indexed') |
|
| 1768 | + $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1769 | + else |
|
| 1770 | + { |
|
| 1771 | + $this->_put('/ColorSpace /'.$info['cs']); |
|
| 1772 | + if($info['cs']=='DeviceCMYK') |
|
| 1773 | + $this->_put('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1774 | + } |
|
| 1775 | + $this->_put('/BitsPerComponent '.$info['bpc']); |
|
| 1776 | + if(isset($info['f'])) |
|
| 1777 | + $this->_put('/Filter /'.$info['f']); |
|
| 1778 | + if(isset($info['dp'])) |
|
| 1779 | + $this->_put('/DecodeParms <<'.$info['dp'].'>>'); |
|
| 1780 | + if(isset($info['trns']) && is_array($info['trns'])) |
|
| 1781 | + { |
|
| 1782 | + $trns = ''; |
|
| 1783 | + for($i=0;$i<count($info['trns']);$i++) |
|
| 1784 | + $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1785 | + $this->_put('/Mask ['.$trns.']'); |
|
| 1786 | + } |
|
| 1787 | + if(isset($info['smask'])) |
|
| 1788 | + $this->_put('/SMask '.($this->n+1).' 0 R'); |
|
| 1789 | + $this->_put('/Length '.strlen($info['data']).'>>'); |
|
| 1790 | + $this->_putstream($info['data']); |
|
| 1791 | + $this->_put('endobj'); |
|
| 1792 | + // Soft mask |
|
| 1793 | + if(isset($info['smask'])) |
|
| 1794 | + { |
|
| 1795 | + $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w']; |
|
| 1796 | + $smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']); |
|
| 1797 | + $this->_putimage($smask); |
|
| 1798 | + } |
|
| 1799 | + // Palette |
|
| 1800 | + if($info['cs']=='Indexed') |
|
| 1801 | + $this->_putstreamobject($info['pal']); |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | protected function _putxobjectdict() |
| 1805 | 1805 | { |
| 1806 | - foreach($this->images as $image) |
|
| 1807 | - $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1806 | + foreach($this->images as $image) |
|
| 1807 | + $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | 1810 | protected function _putresourcedict() |
| 1811 | 1811 | { |
| 1812 | - $this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
|
| 1813 | - $this->_put('/Font <<'); |
|
| 1814 | - foreach($this->fonts as $font) |
|
| 1815 | - $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1816 | - $this->_put('>>'); |
|
| 1817 | - $this->_put('/XObject <<'); |
|
| 1818 | - $this->_putxobjectdict(); |
|
| 1819 | - $this->_put('>>'); |
|
| 1812 | + $this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
|
| 1813 | + $this->_put('/Font <<'); |
|
| 1814 | + foreach($this->fonts as $font) |
|
| 1815 | + $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1816 | + $this->_put('>>'); |
|
| 1817 | + $this->_put('/XObject <<'); |
|
| 1818 | + $this->_putxobjectdict(); |
|
| 1819 | + $this->_put('>>'); |
|
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | 1822 | protected function _putresources() |
| 1823 | 1823 | { |
| 1824 | - $this->_putfonts(); |
|
| 1825 | - $this->_putimages(); |
|
| 1826 | - // Resource dictionary |
|
| 1827 | - $this->_newobj(2); |
|
| 1828 | - $this->_put('<<'); |
|
| 1829 | - $this->_putresourcedict(); |
|
| 1830 | - $this->_put('>>'); |
|
| 1831 | - $this->_put('endobj'); |
|
| 1824 | + $this->_putfonts(); |
|
| 1825 | + $this->_putimages(); |
|
| 1826 | + // Resource dictionary |
|
| 1827 | + $this->_newobj(2); |
|
| 1828 | + $this->_put('<<'); |
|
| 1829 | + $this->_putresourcedict(); |
|
| 1830 | + $this->_put('>>'); |
|
| 1831 | + $this->_put('endobj'); |
|
| 1832 | 1832 | } |
| 1833 | 1833 | |
| 1834 | 1834 | protected function _putinfo() |
| 1835 | 1835 | { |
| 1836 | - $this->metadata['Producer'] = 'FPDF '.FPDF_VERSION; |
|
| 1837 | - $this->metadata['CreationDate'] = 'D:'.@date('YmdHis'); |
|
| 1838 | - foreach($this->metadata as $key=>$value) |
|
| 1839 | - $this->_put('/'.$key.' '.$this->_textstring($value)); |
|
| 1836 | + $this->metadata['Producer'] = 'FPDF '.FPDF_VERSION; |
|
| 1837 | + $this->metadata['CreationDate'] = 'D:'.@date('YmdHis'); |
|
| 1838 | + foreach($this->metadata as $key=>$value) |
|
| 1839 | + $this->_put('/'.$key.' '.$this->_textstring($value)); |
|
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | protected function _putcatalog() |
| 1843 | 1843 | { |
| 1844 | - $n = $this->PageInfo[1]['n']; |
|
| 1845 | - $this->_put('/Type /Catalog'); |
|
| 1846 | - $this->_put('/Pages 1 0 R'); |
|
| 1847 | - if($this->ZoomMode=='fullpage') |
|
| 1848 | - $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); |
|
| 1849 | - elseif($this->ZoomMode=='fullwidth') |
|
| 1850 | - $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); |
|
| 1851 | - elseif($this->ZoomMode=='real') |
|
| 1852 | - $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); |
|
| 1853 | - elseif(!is_string($this->ZoomMode)) |
|
| 1854 | - $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); |
|
| 1855 | - if($this->LayoutMode=='single') |
|
| 1856 | - $this->_put('/PageLayout /SinglePage'); |
|
| 1857 | - elseif($this->LayoutMode=='continuous') |
|
| 1858 | - $this->_put('/PageLayout /OneColumn'); |
|
| 1859 | - elseif($this->LayoutMode=='two') |
|
| 1860 | - $this->_put('/PageLayout /TwoColumnLeft'); |
|
| 1844 | + $n = $this->PageInfo[1]['n']; |
|
| 1845 | + $this->_put('/Type /Catalog'); |
|
| 1846 | + $this->_put('/Pages 1 0 R'); |
|
| 1847 | + if($this->ZoomMode=='fullpage') |
|
| 1848 | + $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); |
|
| 1849 | + elseif($this->ZoomMode=='fullwidth') |
|
| 1850 | + $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); |
|
| 1851 | + elseif($this->ZoomMode=='real') |
|
| 1852 | + $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); |
|
| 1853 | + elseif(!is_string($this->ZoomMode)) |
|
| 1854 | + $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); |
|
| 1855 | + if($this->LayoutMode=='single') |
|
| 1856 | + $this->_put('/PageLayout /SinglePage'); |
|
| 1857 | + elseif($this->LayoutMode=='continuous') |
|
| 1858 | + $this->_put('/PageLayout /OneColumn'); |
|
| 1859 | + elseif($this->LayoutMode=='two') |
|
| 1860 | + $this->_put('/PageLayout /TwoColumnLeft'); |
|
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | 1863 | protected function _putheader() |
| 1864 | 1864 | { |
| 1865 | - $this->_put('%PDF-'.$this->PDFVersion); |
|
| 1865 | + $this->_put('%PDF-'.$this->PDFVersion); |
|
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | 1868 | protected function _puttrailer() |
| 1869 | 1869 | { |
| 1870 | - $this->_put('/Size '.($this->n+1)); |
|
| 1871 | - $this->_put('/Root '.$this->n.' 0 R'); |
|
| 1872 | - $this->_put('/Info '.($this->n-1).' 0 R'); |
|
| 1870 | + $this->_put('/Size '.($this->n+1)); |
|
| 1871 | + $this->_put('/Root '.$this->n.' 0 R'); |
|
| 1872 | + $this->_put('/Info '.($this->n-1).' 0 R'); |
|
| 1873 | 1873 | } |
| 1874 | 1874 | |
| 1875 | 1875 | protected function _enddoc() |
| 1876 | 1876 | { |
| 1877 | - $this->_putheader(); |
|
| 1878 | - $this->_putpages(); |
|
| 1879 | - $this->_putresources(); |
|
| 1880 | - // Info |
|
| 1881 | - $this->_newobj(); |
|
| 1882 | - $this->_put('<<'); |
|
| 1883 | - $this->_putinfo(); |
|
| 1884 | - $this->_put('>>'); |
|
| 1885 | - $this->_put('endobj'); |
|
| 1886 | - // Catalog |
|
| 1887 | - $this->_newobj(); |
|
| 1888 | - $this->_put('<<'); |
|
| 1889 | - $this->_putcatalog(); |
|
| 1890 | - $this->_put('>>'); |
|
| 1891 | - $this->_put('endobj'); |
|
| 1892 | - // Cross-ref |
|
| 1893 | - $offset = $this->_getoffset(); |
|
| 1894 | - $this->_put('xref'); |
|
| 1895 | - $this->_put('0 '.($this->n+1)); |
|
| 1896 | - $this->_put('0000000000 65535 f '); |
|
| 1897 | - for($i=1;$i<=$this->n;$i++) |
|
| 1898 | - $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1899 | - // Trailer |
|
| 1900 | - $this->_put('trailer'); |
|
| 1901 | - $this->_put('<<'); |
|
| 1902 | - $this->_puttrailer(); |
|
| 1903 | - $this->_put('>>'); |
|
| 1904 | - $this->_put('startxref'); |
|
| 1905 | - $this->_put($offset); |
|
| 1906 | - $this->_put('%%EOF'); |
|
| 1907 | - $this->state = 3; |
|
| 1877 | + $this->_putheader(); |
|
| 1878 | + $this->_putpages(); |
|
| 1879 | + $this->_putresources(); |
|
| 1880 | + // Info |
|
| 1881 | + $this->_newobj(); |
|
| 1882 | + $this->_put('<<'); |
|
| 1883 | + $this->_putinfo(); |
|
| 1884 | + $this->_put('>>'); |
|
| 1885 | + $this->_put('endobj'); |
|
| 1886 | + // Catalog |
|
| 1887 | + $this->_newobj(); |
|
| 1888 | + $this->_put('<<'); |
|
| 1889 | + $this->_putcatalog(); |
|
| 1890 | + $this->_put('>>'); |
|
| 1891 | + $this->_put('endobj'); |
|
| 1892 | + // Cross-ref |
|
| 1893 | + $offset = $this->_getoffset(); |
|
| 1894 | + $this->_put('xref'); |
|
| 1895 | + $this->_put('0 '.($this->n+1)); |
|
| 1896 | + $this->_put('0000000000 65535 f '); |
|
| 1897 | + for($i=1;$i<=$this->n;$i++) |
|
| 1898 | + $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1899 | + // Trailer |
|
| 1900 | + $this->_put('trailer'); |
|
| 1901 | + $this->_put('<<'); |
|
| 1902 | + $this->_puttrailer(); |
|
| 1903 | + $this->_put('>>'); |
|
| 1904 | + $this->_put('startxref'); |
|
| 1905 | + $this->_put($offset); |
|
| 1906 | + $this->_put('%%EOF'); |
|
| 1907 | + $this->state = 3; |
|
| 1908 | 1908 | } |
| 1909 | 1909 | } |
| 1910 | 1910 | ?> |
@@ -7,71 +7,71 @@ discard block |
||
| 7 | 7 | * Author: Olivier PLATHEY * |
| 8 | 8 | *******************************************************************************/ |
| 9 | 9 | |
| 10 | -define('FPDF_VERSION','1.83'); |
|
| 10 | +define('FPDF_VERSION', '1.83'); |
|
| 11 | 11 | |
| 12 | 12 | class FPDF |
| 13 | 13 | { |
| 14 | -protected $page; // current page number |
|
| 15 | -protected $n; // current object number |
|
| 16 | -protected $offsets; // array of object offsets |
|
| 17 | -protected $buffer; // buffer holding in-memory PDF |
|
| 18 | -protected $pages; // array containing pages |
|
| 19 | -protected $state; // current document state |
|
| 20 | -protected $compress; // compression flag |
|
| 21 | -protected $k; // scale factor (number of points in user unit) |
|
| 22 | -protected $DefOrientation; // default orientation |
|
| 23 | -protected $CurOrientation; // current orientation |
|
| 24 | -protected $StdPageSizes; // standard page sizes |
|
| 25 | -protected $DefPageSize; // default page size |
|
| 26 | -protected $CurPageSize; // current page size |
|
| 27 | -protected $CurRotation; // current page rotation |
|
| 28 | -protected $PageInfo; // page-related data |
|
| 29 | -protected $wPt, $hPt; // dimensions of current page in points |
|
| 30 | -protected $w, $h; // dimensions of current page in user unit |
|
| 31 | -protected $lMargin; // left margin |
|
| 32 | -protected $tMargin; // top margin |
|
| 33 | -protected $rMargin; // right margin |
|
| 34 | -protected $bMargin; // page break margin |
|
| 35 | -protected $cMargin; // cell margin |
|
| 36 | -protected $x, $y; // current position in user unit |
|
| 37 | -protected $lasth; // height of last printed cell |
|
| 38 | -protected $LineWidth; // line width in user unit |
|
| 39 | -protected $fontpath; // path containing fonts |
|
| 40 | -protected $CoreFonts; // array of core font names |
|
| 41 | -protected $fonts; // array of used fonts |
|
| 42 | -protected $FontFiles; // array of font files |
|
| 43 | -protected $encodings; // array of encodings |
|
| 44 | -protected $cmaps; // array of ToUnicode CMaps |
|
| 45 | -protected $FontFamily; // current font family |
|
| 46 | -protected $FontStyle; // current font style |
|
| 47 | -protected $underline; // underlining flag |
|
| 48 | -protected $CurrentFont; // current font info |
|
| 49 | -protected $FontSizePt; // current font size in points |
|
| 50 | -protected $FontSize; // current font size in user unit |
|
| 51 | -protected $DrawColor; // commands for drawing color |
|
| 52 | -protected $FillColor; // commands for filling color |
|
| 53 | -protected $TextColor; // commands for text color |
|
| 54 | -protected $ColorFlag; // indicates whether fill and text colors are different |
|
| 55 | -protected $WithAlpha; // indicates whether alpha channel is used |
|
| 56 | -protected $ws; // word spacing |
|
| 57 | -protected $images; // array of used images |
|
| 58 | -protected $PageLinks; // array of links in pages |
|
| 59 | -protected $links; // array of internal links |
|
| 60 | -protected $AutoPageBreak; // automatic page breaking |
|
| 61 | -protected $PageBreakTrigger; // threshold used to trigger page breaks |
|
| 62 | -protected $InHeader; // flag set when processing header |
|
| 63 | -protected $InFooter; // flag set when processing footer |
|
| 64 | -protected $AliasNbPages; // alias for total number of pages |
|
| 65 | -protected $ZoomMode; // zoom display mode |
|
| 66 | -protected $LayoutMode; // layout display mode |
|
| 67 | -protected $metadata; // document properties |
|
| 68 | -protected $PDFVersion; // PDF version number |
|
| 14 | +protected $page; // current page number |
|
| 15 | +protected $n; // current object number |
|
| 16 | +protected $offsets; // array of object offsets |
|
| 17 | +protected $buffer; // buffer holding in-memory PDF |
|
| 18 | +protected $pages; // array containing pages |
|
| 19 | +protected $state; // current document state |
|
| 20 | +protected $compress; // compression flag |
|
| 21 | +protected $k; // scale factor (number of points in user unit) |
|
| 22 | +protected $DefOrientation; // default orientation |
|
| 23 | +protected $CurOrientation; // current orientation |
|
| 24 | +protected $StdPageSizes; // standard page sizes |
|
| 25 | +protected $DefPageSize; // default page size |
|
| 26 | +protected $CurPageSize; // current page size |
|
| 27 | +protected $CurRotation; // current page rotation |
|
| 28 | +protected $PageInfo; // page-related data |
|
| 29 | +protected $wPt, $hPt; // dimensions of current page in points |
|
| 30 | +protected $w, $h; // dimensions of current page in user unit |
|
| 31 | +protected $lMargin; // left margin |
|
| 32 | +protected $tMargin; // top margin |
|
| 33 | +protected $rMargin; // right margin |
|
| 34 | +protected $bMargin; // page break margin |
|
| 35 | +protected $cMargin; // cell margin |
|
| 36 | +protected $x, $y; // current position in user unit |
|
| 37 | +protected $lasth; // height of last printed cell |
|
| 38 | +protected $LineWidth; // line width in user unit |
|
| 39 | +protected $fontpath; // path containing fonts |
|
| 40 | +protected $CoreFonts; // array of core font names |
|
| 41 | +protected $fonts; // array of used fonts |
|
| 42 | +protected $FontFiles; // array of font files |
|
| 43 | +protected $encodings; // array of encodings |
|
| 44 | +protected $cmaps; // array of ToUnicode CMaps |
|
| 45 | +protected $FontFamily; // current font family |
|
| 46 | +protected $FontStyle; // current font style |
|
| 47 | +protected $underline; // underlining flag |
|
| 48 | +protected $CurrentFont; // current font info |
|
| 49 | +protected $FontSizePt; // current font size in points |
|
| 50 | +protected $FontSize; // current font size in user unit |
|
| 51 | +protected $DrawColor; // commands for drawing color |
|
| 52 | +protected $FillColor; // commands for filling color |
|
| 53 | +protected $TextColor; // commands for text color |
|
| 54 | +protected $ColorFlag; // indicates whether fill and text colors are different |
|
| 55 | +protected $WithAlpha; // indicates whether alpha channel is used |
|
| 56 | +protected $ws; // word spacing |
|
| 57 | +protected $images; // array of used images |
|
| 58 | +protected $PageLinks; // array of links in pages |
|
| 59 | +protected $links; // array of internal links |
|
| 60 | +protected $AutoPageBreak; // automatic page breaking |
|
| 61 | +protected $PageBreakTrigger; // threshold used to trigger page breaks |
|
| 62 | +protected $InHeader; // flag set when processing header |
|
| 63 | +protected $InFooter; // flag set when processing footer |
|
| 64 | +protected $AliasNbPages; // alias for total number of pages |
|
| 65 | +protected $ZoomMode; // zoom display mode |
|
| 66 | +protected $LayoutMode; // layout display mode |
|
| 67 | +protected $metadata; // document properties |
|
| 68 | +protected $PDFVersion; // PDF version number |
|
| 69 | 69 | |
| 70 | 70 | /******************************************************************************* |
| 71 | 71 | * Public methods * |
| 72 | 72 | *******************************************************************************/ |
| 73 | 73 | |
| 74 | -function __construct($orientation='P', $unit='mm', $size='A4') |
|
| 74 | +function __construct($orientation = 'P', $unit = 'mm', $size = 'A4') |
|
| 75 | 75 | { |
| 76 | 76 | // Some checks |
| 77 | 77 | $this->_dochecks(); |
@@ -102,44 +102,44 @@ discard block |
||
| 102 | 102 | $this->WithAlpha = false; |
| 103 | 103 | $this->ws = 0; |
| 104 | 104 | // Font path |
| 105 | - if(defined('FPDF_FONTPATH')) |
|
| 105 | + if (defined('FPDF_FONTPATH')) |
|
| 106 | 106 | { |
| 107 | 107 | $this->fontpath = FPDF_FONTPATH; |
| 108 | - if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') |
|
| 108 | + if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\') |
|
| 109 | 109 | $this->fontpath .= '/'; |
| 110 | 110 | } |
| 111 | - elseif(is_dir(dirname(__FILE__).'/font')) |
|
| 111 | + elseif (is_dir(dirname(__FILE__).'/font')) |
|
| 112 | 112 | $this->fontpath = dirname(__FILE__).'/font/'; |
| 113 | 113 | else |
| 114 | 114 | $this->fontpath = ''; |
| 115 | 115 | // Core fonts |
| 116 | - $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats','verdana','calligra','Arimo-Regular'); |
|
| 116 | + $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats', 'verdana', 'calligra', 'Arimo-Regular'); |
|
| 117 | 117 | // Scale factor |
| 118 | - if($unit=='pt') |
|
| 118 | + if ($unit == 'pt') |
|
| 119 | 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') |
|
| 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 | 125 | $this->k = 72; |
| 126 | 126 | else |
| 127 | 127 | $this->Error('Incorrect unit: '.$unit); |
| 128 | 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)); |
|
| 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 | 131 | $size = $this->_getpagesize($size); |
| 132 | 132 | $this->DefPageSize = $size; |
| 133 | 133 | $this->CurPageSize = $size; |
| 134 | 134 | // Page orientation |
| 135 | 135 | $orientation = strtolower($orientation); |
| 136 | - if($orientation=='p' || $orientation=='portrait') |
|
| 136 | + if ($orientation == 'p' || $orientation == 'portrait') |
|
| 137 | 137 | { |
| 138 | 138 | $this->DefOrientation = 'P'; |
| 139 | 139 | $this->w = $size[0]; |
| 140 | 140 | $this->h = $size[1]; |
| 141 | 141 | } |
| 142 | - elseif($orientation=='l' || $orientation=='landscape') |
|
| 142 | + elseif ($orientation == 'l' || $orientation == 'landscape') |
|
| 143 | 143 | { |
| 144 | 144 | $this->DefOrientation = 'L'; |
| 145 | 145 | $this->w = $size[1]; |
@@ -148,19 +148,19 @@ discard block |
||
| 148 | 148 | else |
| 149 | 149 | $this->Error('Incorrect orientation: '.$orientation); |
| 150 | 150 | $this->CurOrientation = $this->DefOrientation; |
| 151 | - $this->wPt = $this->w*$this->k; |
|
| 152 | - $this->hPt = $this->h*$this->k; |
|
| 151 | + $this->wPt = $this->w * $this->k; |
|
| 152 | + $this->hPt = $this->h * $this->k; |
|
| 153 | 153 | // Page rotation |
| 154 | 154 | $this->CurRotation = 0; |
| 155 | 155 | // Page margins (1 cm) |
| 156 | - $margin = 28.35/$this->k; |
|
| 157 | - $this->SetMargins($margin,$margin); |
|
| 156 | + $margin = 28.35 / $this->k; |
|
| 157 | + $this->SetMargins($margin, $margin); |
|
| 158 | 158 | // Interior cell margin (1 mm) |
| 159 | - $this->cMargin = $margin/10; |
|
| 159 | + $this->cMargin = $margin / 10; |
|
| 160 | 160 | // Line width (0.2 mm) |
| 161 | - $this->LineWidth = .567/$this->k; |
|
| 161 | + $this->LineWidth = .567 / $this->k; |
|
| 162 | 162 | // Automatic page break |
| 163 | - $this->SetAutoPageBreak(true,2*$margin); |
|
| 163 | + $this->SetAutoPageBreak(true, 2 * $margin); |
|
| 164 | 164 | // Default display mode |
| 165 | 165 | $this->SetDisplayMode('default'); |
| 166 | 166 | // Enable compression |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | $this->PDFVersion = '1.3'; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | -function SetMargins($left, $top, $right=null) |
|
| 172 | +function SetMargins($left, $top, $right = null) |
|
| 173 | 173 | { |
| 174 | 174 | // Set left, top and right margins |
| 175 | 175 | $this->lMargin = $left; |
| 176 | 176 | $this->tMargin = $top; |
| 177 | - if($right===null) |
|
| 177 | + if ($right === null) |
|
| 178 | 178 | $right = $left; |
| 179 | 179 | $this->rMargin = $right; |
| 180 | 180 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | // Set left margin |
| 185 | 185 | $this->lMargin = $margin; |
| 186 | - if($this->page>0 && $this->x<$margin) |
|
| 186 | + if ($this->page > 0 && $this->x < $margin) |
|
| 187 | 187 | $this->x = $margin; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -199,22 +199,22 @@ discard block |
||
| 199 | 199 | $this->rMargin = $margin; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | -function SetAutoPageBreak($auto, $margin=0) |
|
| 202 | +function SetAutoPageBreak($auto, $margin = 0) |
|
| 203 | 203 | { |
| 204 | 204 | // Set auto page break mode and triggering margin |
| 205 | 205 | $this->AutoPageBreak = $auto; |
| 206 | 206 | $this->bMargin = $margin; |
| 207 | - $this->PageBreakTrigger = $this->h-$margin; |
|
| 207 | + $this->PageBreakTrigger = $this->h - $margin; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | -function SetDisplayMode($zoom, $layout='default') |
|
| 210 | +function SetDisplayMode($zoom, $layout = 'default') |
|
| 211 | 211 | { |
| 212 | 212 | // Set display mode in viewer |
| 213 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
| 213 | + if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom)) |
|
| 214 | 214 | $this->ZoomMode = $zoom; |
| 215 | 215 | else |
| 216 | 216 | $this->Error('Incorrect zoom display mode: '.$zoom); |
| 217 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
| 217 | + if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') |
|
| 218 | 218 | $this->LayoutMode = $layout; |
| 219 | 219 | else |
| 220 | 220 | $this->Error('Incorrect layout display mode: '.$layout); |
@@ -223,43 +223,43 @@ discard block |
||
| 223 | 223 | function SetCompression($compress) |
| 224 | 224 | { |
| 225 | 225 | // Set page compression |
| 226 | - if(function_exists('gzcompress')) |
|
| 226 | + if (function_exists('gzcompress')) |
|
| 227 | 227 | $this->compress = $compress; |
| 228 | 228 | else |
| 229 | 229 | $this->compress = false; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | -function SetTitle($title, $isUTF8=false) |
|
| 232 | +function SetTitle($title, $isUTF8 = false) |
|
| 233 | 233 | { |
| 234 | 234 | // Title of document |
| 235 | 235 | $this->metadata['Title'] = $isUTF8 ? $title : utf8_encode($title); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | -function SetAuthor($author, $isUTF8=false) |
|
| 238 | +function SetAuthor($author, $isUTF8 = false) |
|
| 239 | 239 | { |
| 240 | 240 | // Author of document |
| 241 | 241 | $this->metadata['Author'] = $isUTF8 ? $author : utf8_encode($author); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | -function SetSubject($subject, $isUTF8=false) |
|
| 244 | +function SetSubject($subject, $isUTF8 = false) |
|
| 245 | 245 | { |
| 246 | 246 | // Subject of document |
| 247 | 247 | $this->metadata['Subject'] = $isUTF8 ? $subject : utf8_encode($subject); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | -function SetKeywords($keywords, $isUTF8=false) |
|
| 250 | +function SetKeywords($keywords, $isUTF8 = false) |
|
| 251 | 251 | { |
| 252 | 252 | // Keywords of document |
| 253 | 253 | $this->metadata['Keywords'] = $isUTF8 ? $keywords : utf8_encode($keywords); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | -function SetCreator($creator, $isUTF8=false) |
|
| 256 | +function SetCreator($creator, $isUTF8 = false) |
|
| 257 | 257 | { |
| 258 | 258 | // Creator of document |
| 259 | 259 | $this->metadata['Creator'] = $isUTF8 ? $creator : utf8_encode($creator); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | -function AliasNbPages($alias='{nb}') |
|
| 262 | +function AliasNbPages($alias = '{nb}') |
|
| 263 | 263 | { |
| 264 | 264 | // Define an alias for total number of pages |
| 265 | 265 | $this->AliasNbPages = $alias; |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | function Close() |
| 275 | 275 | { |
| 276 | 276 | // Terminate document |
| 277 | - if($this->state==3) |
|
| 277 | + if ($this->state == 3) |
|
| 278 | 278 | return; |
| 279 | - if($this->page==0) |
|
| 279 | + if ($this->page == 0) |
|
| 280 | 280 | $this->AddPage(); |
| 281 | 281 | // Page footer |
| 282 | 282 | $this->InFooter = true; |
@@ -288,10 +288,10 @@ discard block |
||
| 288 | 288 | $this->_enddoc(); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | -function AddPage($orientation='', $size='', $rotation=0) |
|
| 291 | +function AddPage($orientation = '', $size = '', $rotation = 0) |
|
| 292 | 292 | { |
| 293 | 293 | // Start a new page |
| 294 | - if($this->state==3) |
|
| 294 | + if ($this->state == 3) |
|
| 295 | 295 | $this->Error('The document is closed'); |
| 296 | 296 | $family = $this->FontFamily; |
| 297 | 297 | $style = $this->FontStyle.($this->underline ? 'U' : ''); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | $fc = $this->FillColor; |
| 302 | 302 | $tc = $this->TextColor; |
| 303 | 303 | $cf = $this->ColorFlag; |
| 304 | - if($this->page>0) |
|
| 304 | + if ($this->page > 0) |
|
| 305 | 305 | { |
| 306 | 306 | // Page footer |
| 307 | 307 | $this->InFooter = true; |
@@ -311,21 +311,21 @@ discard block |
||
| 311 | 311 | $this->_endpage(); |
| 312 | 312 | } |
| 313 | 313 | // Start new page |
| 314 | - $this->_beginpage($orientation,$size,$rotation); |
|
| 314 | + $this->_beginpage($orientation, $size, $rotation); |
|
| 315 | 315 | // Set line cap style to square |
| 316 | 316 | $this->_out('2 J'); |
| 317 | 317 | // Set line width |
| 318 | 318 | $this->LineWidth = $lw; |
| 319 | - $this->_out(sprintf('%.2F w',$lw*$this->k)); |
|
| 319 | + $this->_out(sprintf('%.2F w', $lw * $this->k)); |
|
| 320 | 320 | // Set font |
| 321 | - if($family) |
|
| 322 | - $this->SetFont($family,$style,$fontsize); |
|
| 321 | + if ($family) |
|
| 322 | + $this->SetFont($family, $style, $fontsize); |
|
| 323 | 323 | // Set colors |
| 324 | 324 | $this->DrawColor = $dc; |
| 325 | - if($dc!='0 G') |
|
| 325 | + if ($dc != '0 G') |
|
| 326 | 326 | $this->_out($dc); |
| 327 | 327 | $this->FillColor = $fc; |
| 328 | - if($fc!='0 g') |
|
| 328 | + if ($fc != '0 g') |
|
| 329 | 329 | $this->_out($fc); |
| 330 | 330 | $this->TextColor = $tc; |
| 331 | 331 | $this->ColorFlag = $cf; |
@@ -334,21 +334,21 @@ discard block |
||
| 334 | 334 | $this->Header(); |
| 335 | 335 | $this->InHeader = false; |
| 336 | 336 | // Restore line width |
| 337 | - if($this->LineWidth!=$lw) |
|
| 337 | + if ($this->LineWidth != $lw) |
|
| 338 | 338 | { |
| 339 | 339 | $this->LineWidth = $lw; |
| 340 | - $this->_out(sprintf('%.2F w',$lw*$this->k)); |
|
| 340 | + $this->_out(sprintf('%.2F w', $lw * $this->k)); |
|
| 341 | 341 | } |
| 342 | 342 | // Restore font |
| 343 | - if($family) |
|
| 344 | - $this->SetFont($family,$style,$fontsize); |
|
| 343 | + if ($family) |
|
| 344 | + $this->SetFont($family, $style, $fontsize); |
|
| 345 | 345 | // Restore colors |
| 346 | - if($this->DrawColor!=$dc) |
|
| 346 | + if ($this->DrawColor != $dc) |
|
| 347 | 347 | { |
| 348 | 348 | $this->DrawColor = $dc; |
| 349 | 349 | $this->_out($dc); |
| 350 | 350 | } |
| 351 | - if($this->FillColor!=$fc) |
|
| 351 | + if ($this->FillColor != $fc) |
|
| 352 | 352 | { |
| 353 | 353 | $this->FillColor = $fc; |
| 354 | 354 | $this->_out($fc); |
@@ -373,95 +373,95 @@ discard block |
||
| 373 | 373 | return $this->page; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | -function SetDrawColor($r, $g=null, $b=null) |
|
| 376 | +function SetDrawColor($r, $g = null, $b = null) |
|
| 377 | 377 | { |
| 378 | 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); |
|
| 379 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
| 380 | + $this->DrawColor = sprintf('%.3F G', $r / 255); |
|
| 381 | 381 | else |
| 382 | - $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 383 | - if($this->page>0) |
|
| 382 | + $this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255); |
|
| 383 | + if ($this->page > 0) |
|
| 384 | 384 | $this->_out($this->DrawColor); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | -function SetFillColor($r, $g=null, $b=null) |
|
| 387 | +function SetFillColor($r, $g = null, $b = null) |
|
| 388 | 388 | { |
| 389 | 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); |
|
| 390 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
| 391 | + $this->FillColor = sprintf('%.3F g', $r / 255); |
|
| 392 | 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) |
|
| 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 | 396 | $this->_out($this->FillColor); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | -function SetTextColor($r, $g=null, $b=null) |
|
| 399 | +function SetTextColor($r, $g = null, $b = null) |
|
| 400 | 400 | { |
| 401 | 401 | // Set color for text |
| 402 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 403 | - $this->TextColor = sprintf('%.3F g',$r/255); |
|
| 402 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
| 403 | + $this->TextColor = sprintf('%.3F g', $r / 255); |
|
| 404 | 404 | else |
| 405 | - $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 406 | - $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
|
| 405 | + $this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
|
| 406 | + $this->ColorFlag = ($this->FillColor != $this->TextColor); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | function GetStringWidth($s) |
| 410 | 410 | { |
| 411 | 411 | // Get width of a string in the current font |
| 412 | - $s = (string)$s; |
|
| 412 | + $s = (string) $s; |
|
| 413 | 413 | $cw = &$this->CurrentFont['cw']; |
| 414 | 414 | $w = 0; |
| 415 | 415 | $l = strlen($s); |
| 416 | - for($i=0;$i<$l;$i++) |
|
| 416 | + for ($i = 0; $i < $l; $i++) |
|
| 417 | 417 | $w += $cw[$s[$i]]; |
| 418 | - return $w*$this->FontSize/1000; |
|
| 418 | + return $w * $this->FontSize / 1000; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | function SetLineWidth($width) |
| 422 | 422 | { |
| 423 | 423 | // Set line width |
| 424 | 424 | $this->LineWidth = $width; |
| 425 | - if($this->page>0) |
|
| 426 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 425 | + if ($this->page > 0) |
|
| 426 | + $this->_out(sprintf('%.2F w', $width * $this->k)); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | function Line($x1, $y1, $x2, $y2) |
| 430 | 430 | { |
| 431 | 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)); |
|
| 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 | 433 | } |
| 434 | 434 | |
| 435 | -function Rect($x, $y, $w, $h, $style='') |
|
| 435 | +function Rect($x, $y, $w, $h, $style = '') |
|
| 436 | 436 | { |
| 437 | 437 | // Draw a rectangle |
| 438 | - if($style=='F') |
|
| 438 | + if ($style == 'F') |
|
| 439 | 439 | $op = 'f'; |
| 440 | - elseif($style=='FD' || $style=='DF') |
|
| 440 | + elseif ($style == 'FD' || $style == 'DF') |
|
| 441 | 441 | $op = 'B'; |
| 442 | 442 | else |
| 443 | 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)); |
|
| 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 | 445 | } |
| 446 | 446 | |
| 447 | -function AddFont($family, $style='', $file='') |
|
| 447 | +function AddFont($family, $style = '', $file = '') |
|
| 448 | 448 | { |
| 449 | 449 | // Add a TrueType, OpenType or Type1 font |
| 450 | 450 | $family = strtolower($family); |
| 451 | - if($file=='') |
|
| 452 | - $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 451 | + if ($file == '') |
|
| 452 | + $file = str_replace(' ', '', $family).strtolower($style).'.php'; |
|
| 453 | 453 | $style = strtoupper($style); |
| 454 | - if($style=='IB') |
|
| 454 | + if ($style == 'IB') |
|
| 455 | 455 | $style = 'BI'; |
| 456 | 456 | $fontkey = $family.$style; |
| 457 | - if(isset($this->fonts[$fontkey])) |
|
| 457 | + if (isset($this->fonts[$fontkey])) |
|
| 458 | 458 | return; |
| 459 | 459 | $info = $this->_loadfont($file); |
| 460 | - $info['i'] = count($this->fonts)+1; |
|
| 461 | - if(!empty($info['file'])) |
|
| 460 | + $info['i'] = count($this->fonts) + 1; |
|
| 461 | + if (!empty($info['file'])) |
|
| 462 | 462 | { |
| 463 | 463 | // Embedded font |
| 464 | - if($info['type']=='TrueType') |
|
| 464 | + if ($info['type'] == 'TrueType') |
|
| 465 | 465 | $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
| 466 | 466 | else |
| 467 | 467 | $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
@@ -469,42 +469,42 @@ discard block |
||
| 469 | 469 | $this->fonts[$fontkey] = $info; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | -function SetFont($family, $style='', $size=0) |
|
| 472 | +function SetFont($family, $style = '', $size = 0) |
|
| 473 | 473 | { |
| 474 | 474 | // Select a font; size given in points |
| 475 | - if($family=='') |
|
| 475 | + if ($family == '') |
|
| 476 | 476 | $family = $this->FontFamily; |
| 477 | 477 | else |
| 478 | 478 | $family = strtolower($family); |
| 479 | 479 | $style = strtoupper($style); |
| 480 | - if(strpos($style,'U')!==false) |
|
| 480 | + if (strpos($style, 'U') !== false) |
|
| 481 | 481 | { |
| 482 | 482 | $this->underline = true; |
| 483 | - $style = str_replace('U','',$style); |
|
| 483 | + $style = str_replace('U', '', $style); |
|
| 484 | 484 | } |
| 485 | 485 | else |
| 486 | 486 | $this->underline = false; |
| 487 | - if($style=='IB') |
|
| 487 | + if ($style == 'IB') |
|
| 488 | 488 | $style = 'BI'; |
| 489 | - if($size==0) |
|
| 489 | + if ($size == 0) |
|
| 490 | 490 | $size = $this->FontSizePt; |
| 491 | 491 | // Test if font is already selected |
| 492 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
| 492 | + if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size) |
|
| 493 | 493 | return; |
| 494 | 494 | // Test if font is already loaded |
| 495 | 495 | $fontkey = $family.$style; |
| 496 | - if(!isset($this->fonts[$fontkey])) |
|
| 496 | + if (!isset($this->fonts[$fontkey])) |
|
| 497 | 497 | { |
| 498 | 498 | // Test if one of the core fonts |
| 499 | - if($family=='arial') |
|
| 499 | + if ($family == 'arial') |
|
| 500 | 500 | $family = 'helvetica'; |
| 501 | - if(in_array($family,$this->CoreFonts)) |
|
| 501 | + if (in_array($family, $this->CoreFonts)) |
|
| 502 | 502 | { |
| 503 | - if($family=='symbol' || $family=='zapfdingbats') |
|
| 503 | + if ($family == 'symbol' || $family == 'zapfdingbats') |
|
| 504 | 504 | $style = ''; |
| 505 | 505 | $fontkey = $family.$style; |
| 506 | - if(!isset($this->fonts[$fontkey])) |
|
| 507 | - $this->AddFont($family,$style); |
|
| 506 | + if (!isset($this->fonts[$fontkey])) |
|
| 507 | + $this->AddFont($family, $style); |
|
| 508 | 508 | } |
| 509 | 509 | else |
| 510 | 510 | $this->Error('Undefined font: '.$family.' '.$style); |
@@ -513,37 +513,37 @@ discard block |
||
| 513 | 513 | $this->FontFamily = $family; |
| 514 | 514 | $this->FontStyle = $style; |
| 515 | 515 | $this->FontSizePt = $size; |
| 516 | - $this->FontSize = $size/$this->k; |
|
| 516 | + $this->FontSize = $size / $this->k; |
|
| 517 | 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)); |
|
| 518 | + if ($this->page > 0) |
|
| 519 | + $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | function SetFontSize($size) |
| 523 | 523 | { |
| 524 | 524 | // Set font size in points |
| 525 | - if($this->FontSizePt==$size) |
|
| 525 | + if ($this->FontSizePt == $size) |
|
| 526 | 526 | return; |
| 527 | 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)); |
|
| 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 | 531 | } |
| 532 | 532 | |
| 533 | 533 | function AddLink() |
| 534 | 534 | { |
| 535 | 535 | // Create a new internal link |
| 536 | - $n = count($this->links)+1; |
|
| 536 | + $n = count($this->links) + 1; |
|
| 537 | 537 | $this->links[$n] = array(0, 0); |
| 538 | 538 | return $n; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | -function SetLink($link, $y=0, $page=-1) |
|
| 541 | +function SetLink($link, $y = 0, $page = -1) |
|
| 542 | 542 | { |
| 543 | 543 | // Set destination of internal link |
| 544 | - if($y==-1) |
|
| 544 | + if ($y == -1) |
|
| 545 | 545 | $y = $this->y; |
| 546 | - if($page==-1) |
|
| 546 | + if ($page == -1) |
|
| 547 | 547 | $page = $this->page; |
| 548 | 548 | $this->links[$link] = array($page, $y); |
| 549 | 549 | } |
@@ -551,18 +551,18 @@ discard block |
||
| 551 | 551 | function Link($x, $y, $w, $h, $link) |
| 552 | 552 | { |
| 553 | 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); |
|
| 554 | + $this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | function Text($x, $y, $txt) |
| 558 | 558 | { |
| 559 | 559 | // Output a string |
| 560 | - if(!isset($this->CurrentFont)) |
|
| 560 | + if (!isset($this->CurrentFont)) |
|
| 561 | 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) |
|
| 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 | 566 | $s = 'q '.$this->TextColor.' '.$s.' Q'; |
| 567 | 567 | $this->_out($s); |
| 568 | 568 | } |
@@ -573,103 +573,103 @@ discard block |
||
| 573 | 573 | return $this->AutoPageBreak; |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | -function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') |
|
| 576 | +function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') |
|
| 577 | 577 | { |
| 578 | 578 | // Output a cell |
| 579 | 579 | $k = $this->k; |
| 580 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 580 | + if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 581 | 581 | { |
| 582 | 582 | // Automatic page break |
| 583 | 583 | $x = $this->x; |
| 584 | 584 | $ws = $this->ws; |
| 585 | - if($ws>0) |
|
| 585 | + if ($ws > 0) |
|
| 586 | 586 | { |
| 587 | 587 | $this->ws = 0; |
| 588 | 588 | $this->_out('0 Tw'); |
| 589 | 589 | } |
| 590 | - $this->AddPage($this->CurOrientation,$this->CurPageSize,$this->CurRotation); |
|
| 590 | + $this->AddPage($this->CurOrientation, $this->CurPageSize, $this->CurRotation); |
|
| 591 | 591 | $this->x = $x; |
| 592 | - if($ws>0) |
|
| 592 | + if ($ws > 0) |
|
| 593 | 593 | { |
| 594 | 594 | $this->ws = $ws; |
| 595 | - $this->_out(sprintf('%.3F Tw',$ws*$k)); |
|
| 595 | + $this->_out(sprintf('%.3F Tw', $ws * $k)); |
|
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | - if($w==0) |
|
| 599 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 598 | + if ($w == 0) |
|
| 599 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 600 | 600 | $s = ''; |
| 601 | - if($fill || $border==1) |
|
| 601 | + if ($fill || $border == 1) |
|
| 602 | 602 | { |
| 603 | - if($fill) |
|
| 604 | - $op = ($border==1) ? 'B' : 'f'; |
|
| 603 | + if ($fill) |
|
| 604 | + $op = ($border == 1) ? 'B' : 'f'; |
|
| 605 | 605 | else |
| 606 | 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); |
|
| 607 | + $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op); |
|
| 608 | 608 | } |
| 609 | - if(is_string($border)) |
|
| 609 | + if (is_string($border)) |
|
| 610 | 610 | { |
| 611 | 611 | $x = $this->x; |
| 612 | 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); |
|
| 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 | 621 | } |
| 622 | - if($txt!=='') |
|
| 622 | + if ($txt !== '') |
|
| 623 | 623 | { |
| 624 | - if(!isset($this->CurrentFont)) |
|
| 624 | + if (!isset($this->CurrentFont)) |
|
| 625 | 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; |
|
| 626 | + if ($align == 'R') |
|
| 627 | + $dx = $w - $this->cMargin - $this->GetStringWidth($txt); |
|
| 628 | + elseif ($align == 'C') |
|
| 629 | + $dx = ($w - $this->GetStringWidth($txt)) / 2; |
|
| 630 | 630 | else |
| 631 | 631 | $dx = $this->cMargin; |
| 632 | - if($this->ColorFlag) |
|
| 632 | + if ($this->ColorFlag) |
|
| 633 | 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) |
|
| 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 | 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); |
|
| 639 | + if ($link) |
|
| 640 | + $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link); |
|
| 641 | 641 | } |
| 642 | - if($s) |
|
| 642 | + if ($s) |
|
| 643 | 643 | $this->_out($s); |
| 644 | 644 | $this->lasth = $h; |
| 645 | - if($ln>0) |
|
| 645 | + if ($ln > 0) |
|
| 646 | 646 | { |
| 647 | 647 | // Go to next line |
| 648 | 648 | $this->y += $h; |
| 649 | - if($ln==1) |
|
| 649 | + if ($ln == 1) |
|
| 650 | 650 | $this->x = $this->lMargin; |
| 651 | 651 | } |
| 652 | 652 | else |
| 653 | 653 | $this->x += $w; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | -function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
|
| 656 | +function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false) |
|
| 657 | 657 | { |
| 658 | 658 | // Output text with automatic or explicit line breaks |
| 659 | - if(!isset($this->CurrentFont)) |
|
| 659 | + if (!isset($this->CurrentFont)) |
|
| 660 | 660 | $this->Error('No font has been set'); |
| 661 | 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); |
|
| 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 | 666 | $nb = strlen($s); |
| 667 | - if($nb>0 && $s[$nb-1]=="\n") |
|
| 667 | + if ($nb > 0 && $s[$nb - 1] == "\n") |
|
| 668 | 668 | $nb--; |
| 669 | 669 | $b = 0; |
| 670 | - if($border) |
|
| 670 | + if ($border) |
|
| 671 | 671 | { |
| 672 | - if($border==1) |
|
| 672 | + if ($border == 1) |
|
| 673 | 673 | { |
| 674 | 674 | $border = 'LTRB'; |
| 675 | 675 | $b = 'LRT'; |
@@ -678,11 +678,11 @@ discard block |
||
| 678 | 678 | else |
| 679 | 679 | { |
| 680 | 680 | $b2 = ''; |
| 681 | - if(strpos($border,'L')!==false) |
|
| 681 | + if (strpos($border, 'L') !== false) |
|
| 682 | 682 | $b2 .= 'L'; |
| 683 | - if(strpos($border,'R')!==false) |
|
| 683 | + if (strpos($border, 'R') !== false) |
|
| 684 | 684 | $b2 .= 'R'; |
| 685 | - $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; |
|
| 685 | + $b = (strpos($border, 'T') !== false) ? $b2.'T' : $b2; |
|
| 686 | 686 | } |
| 687 | 687 | } |
| 688 | 688 | $sep = -1; |
@@ -691,155 +691,155 @@ discard block |
||
| 691 | 691 | $l = 0; |
| 692 | 692 | $ns = 0; |
| 693 | 693 | $nl = 1; |
| 694 | - while($i<$nb) |
|
| 694 | + while ($i < $nb) |
|
| 695 | 695 | { |
| 696 | 696 | // Get next character |
| 697 | 697 | $c = $s[$i]; |
| 698 | - if($c=="\n") |
|
| 698 | + if ($c == "\n") |
|
| 699 | 699 | { |
| 700 | 700 | // Explicit line break |
| 701 | - if($this->ws>0) |
|
| 701 | + if ($this->ws > 0) |
|
| 702 | 702 | { |
| 703 | 703 | $this->ws = 0; |
| 704 | 704 | $this->_out('0 Tw'); |
| 705 | 705 | } |
| 706 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
| 706 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
| 707 | 707 | $i++; |
| 708 | 708 | $sep = -1; |
| 709 | 709 | $j = $i; |
| 710 | 710 | $l = 0; |
| 711 | 711 | $ns = 0; |
| 712 | 712 | $nl++; |
| 713 | - if($border && $nl==2) |
|
| 713 | + if ($border && $nl == 2) |
|
| 714 | 714 | $b = $b2; |
| 715 | 715 | continue; |
| 716 | 716 | } |
| 717 | - if($c==' ') |
|
| 717 | + if ($c == ' ') |
|
| 718 | 718 | { |
| 719 | 719 | $sep = $i; |
| 720 | 720 | $ls = $l; |
| 721 | 721 | $ns++; |
| 722 | 722 | } |
| 723 | 723 | $l += $cw[$c]; |
| 724 | - if($l>$wmax) |
|
| 724 | + if ($l > $wmax) |
|
| 725 | 725 | { |
| 726 | 726 | // Automatic line break |
| 727 | - if($sep==-1) |
|
| 727 | + if ($sep == -1) |
|
| 728 | 728 | { |
| 729 | - if($i==$j) |
|
| 729 | + if ($i == $j) |
|
| 730 | 730 | $i++; |
| 731 | - if($this->ws>0) |
|
| 731 | + if ($this->ws > 0) |
|
| 732 | 732 | { |
| 733 | 733 | $this->ws = 0; |
| 734 | 734 | $this->_out('0 Tw'); |
| 735 | 735 | } |
| 736 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
| 736 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
| 737 | 737 | } |
| 738 | 738 | else |
| 739 | 739 | { |
| 740 | - if($align=='J') |
|
| 740 | + if ($align == 'J') |
|
| 741 | 741 | { |
| 742 | - $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; |
|
| 743 | - $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); |
|
| 742 | + $this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0; |
|
| 743 | + $this->_out(sprintf('%.3F Tw', $this->ws * $this->k)); |
|
| 744 | 744 | } |
| 745 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); |
|
| 746 | - $i = $sep+1; |
|
| 745 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill); |
|
| 746 | + $i = $sep + 1; |
|
| 747 | 747 | } |
| 748 | 748 | $sep = -1; |
| 749 | 749 | $j = $i; |
| 750 | 750 | $l = 0; |
| 751 | 751 | $ns = 0; |
| 752 | 752 | $nl++; |
| 753 | - if($border && $nl==2) |
|
| 753 | + if ($border && $nl == 2) |
|
| 754 | 754 | $b = $b2; |
| 755 | 755 | } |
| 756 | 756 | else |
| 757 | 757 | $i++; |
| 758 | 758 | } |
| 759 | 759 | // Last chunk |
| 760 | - if($this->ws>0) |
|
| 760 | + if ($this->ws > 0) |
|
| 761 | 761 | { |
| 762 | 762 | $this->ws = 0; |
| 763 | 763 | $this->_out('0 Tw'); |
| 764 | 764 | } |
| 765 | - if($border && strpos($border,'B')!==false) |
|
| 765 | + if ($border && strpos($border, 'B') !== false) |
|
| 766 | 766 | $b .= 'B'; |
| 767 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
| 767 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
| 768 | 768 | $this->x = $this->lMargin; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | -function Write($h, $txt, $link='') |
|
| 771 | +function Write($h, $txt, $link = '') |
|
| 772 | 772 | { |
| 773 | 773 | // Output text in flowing mode |
| 774 | - if(!isset($this->CurrentFont)) |
|
| 774 | + if (!isset($this->CurrentFont)) |
|
| 775 | 775 | $this->Error('No font has been set'); |
| 776 | 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); |
|
| 777 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 778 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 779 | + $s = str_replace("\r", '', $txt); |
|
| 780 | 780 | $nb = strlen($s); |
| 781 | 781 | $sep = -1; |
| 782 | 782 | $i = 0; |
| 783 | 783 | $j = 0; |
| 784 | 784 | $l = 0; |
| 785 | 785 | $nl = 1; |
| 786 | - while($i<$nb) |
|
| 786 | + while ($i < $nb) |
|
| 787 | 787 | { |
| 788 | 788 | // Get next character |
| 789 | 789 | $c = $s[$i]; |
| 790 | - if($c=="\n") |
|
| 790 | + if ($c == "\n") |
|
| 791 | 791 | { |
| 792 | 792 | // Explicit line break |
| 793 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
|
| 793 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', false, $link); |
|
| 794 | 794 | $i++; |
| 795 | 795 | $sep = -1; |
| 796 | 796 | $j = $i; |
| 797 | 797 | $l = 0; |
| 798 | - if($nl==1) |
|
| 798 | + if ($nl == 1) |
|
| 799 | 799 | { |
| 800 | 800 | $this->x = $this->lMargin; |
| 801 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 802 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 801 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 802 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 803 | 803 | } |
| 804 | 804 | $nl++; |
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | - if($c==' ') |
|
| 807 | + if ($c == ' ') |
|
| 808 | 808 | $sep = $i; |
| 809 | 809 | $l += $cw[$c]; |
| 810 | - if($l>$wmax) |
|
| 810 | + if ($l > $wmax) |
|
| 811 | 811 | { |
| 812 | 812 | // Automatic line break |
| 813 | - if($sep==-1) |
|
| 813 | + if ($sep == -1) |
|
| 814 | 814 | { |
| 815 | - if($this->x>$this->lMargin) |
|
| 815 | + if ($this->x > $this->lMargin) |
|
| 816 | 816 | { |
| 817 | 817 | // Move to next line |
| 818 | 818 | $this->x = $this->lMargin; |
| 819 | 819 | $this->y += $h; |
| 820 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 821 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 820 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 821 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 822 | 822 | $i++; |
| 823 | 823 | $nl++; |
| 824 | 824 | continue; |
| 825 | 825 | } |
| 826 | - if($i==$j) |
|
| 826 | + if ($i == $j) |
|
| 827 | 827 | $i++; |
| 828 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
|
| 828 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', false, $link); |
|
| 829 | 829 | } |
| 830 | 830 | else |
| 831 | 831 | { |
| 832 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); |
|
| 833 | - $i = $sep+1; |
|
| 832 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', false, $link); |
|
| 833 | + $i = $sep + 1; |
|
| 834 | 834 | } |
| 835 | 835 | $sep = -1; |
| 836 | 836 | $j = $i; |
| 837 | 837 | $l = 0; |
| 838 | - if($nl==1) |
|
| 838 | + if ($nl == 1) |
|
| 839 | 839 | { |
| 840 | 840 | $this->x = $this->lMargin; |
| 841 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 842 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 841 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 842 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 843 | 843 | } |
| 844 | 844 | $nl++; |
| 845 | 845 | } |
@@ -847,83 +847,83 @@ discard block |
||
| 847 | 847 | $i++; |
| 848 | 848 | } |
| 849 | 849 | // Last chunk |
| 850 | - if($i!=$j) |
|
| 851 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
| 850 | + if ($i != $j) |
|
| 851 | + $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', false, $link); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | -function Ln($h=null) |
|
| 854 | +function Ln($h = null) |
|
| 855 | 855 | { |
| 856 | 856 | // Line feed; default value is the last cell height |
| 857 | 857 | $this->x = $this->lMargin; |
| 858 | - if($h===null) |
|
| 858 | + if ($h === null) |
|
| 859 | 859 | $this->y += $this->lasth; |
| 860 | 860 | else |
| 861 | 861 | $this->y += $h; |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | -function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
|
| 864 | +function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') |
|
| 865 | 865 | { |
| 866 | 866 | // Put an image on the page |
| 867 | - if($file=='') |
|
| 867 | + if ($file == '') |
|
| 868 | 868 | $this->Error('Image file name is empty'); |
| 869 | - if(!isset($this->images[$file])) |
|
| 869 | + if (!isset($this->images[$file])) |
|
| 870 | 870 | { |
| 871 | 871 | // First use of this image, get info |
| 872 | - if($type=='') |
|
| 872 | + if ($type == '') |
|
| 873 | 873 | { |
| 874 | - $pos = strrpos($file,'.'); |
|
| 875 | - if(!$pos) |
|
| 874 | + $pos = strrpos($file, '.'); |
|
| 875 | + if (!$pos) |
|
| 876 | 876 | $this->Error('Image file has no extension and no type was specified: '.$file); |
| 877 | - $type = substr($file,$pos+1); |
|
| 877 | + $type = substr($file, $pos + 1); |
|
| 878 | 878 | } |
| 879 | 879 | $type = strtolower($type); |
| 880 | - if($type=='jpeg') |
|
| 880 | + if ($type == 'jpeg') |
|
| 881 | 881 | $type = 'jpg'; |
| 882 | 882 | $mtd = '_parse'.$type; |
| 883 | - if(!method_exists($this,$mtd)) |
|
| 883 | + if (!method_exists($this, $mtd)) |
|
| 884 | 884 | $this->Error('Unsupported image type: '.$type); |
| 885 | 885 | $info = $this->$mtd($file); |
| 886 | - $info['i'] = count($this->images)+1; |
|
| 886 | + $info['i'] = count($this->images) + 1; |
|
| 887 | 887 | $this->images[$file] = $info; |
| 888 | 888 | } |
| 889 | 889 | else |
| 890 | 890 | $info = $this->images[$file]; |
| 891 | 891 | |
| 892 | 892 | // Automatic width and height calculation if needed |
| 893 | - if($w==0 && $h==0) |
|
| 893 | + if ($w == 0 && $h == 0) |
|
| 894 | 894 | { |
| 895 | 895 | // Put image at 96 dpi |
| 896 | 896 | $w = -96; |
| 897 | 897 | $h = -96; |
| 898 | 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']; |
|
| 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 | 907 | |
| 908 | 908 | // Flowing mode |
| 909 | - if($y===null) |
|
| 909 | + if ($y === null) |
|
| 910 | 910 | { |
| 911 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 911 | + if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 912 | 912 | { |
| 913 | 913 | // Automatic page break |
| 914 | 914 | $x2 = $this->x; |
| 915 | - $this->AddPage($this->CurOrientation,$this->CurPageSize,$this->CurRotation); |
|
| 915 | + $this->AddPage($this->CurOrientation, $this->CurPageSize, $this->CurRotation); |
|
| 916 | 916 | $this->x = $x2; |
| 917 | 917 | } |
| 918 | 918 | $y = $this->y; |
| 919 | 919 | $this->y += $h; |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - if($x===null) |
|
| 922 | + if ($x === null) |
|
| 923 | 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); |
|
| 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 | 927 | } |
| 928 | 928 | |
| 929 | 929 | function GetPageWidth() |
@@ -947,10 +947,10 @@ discard block |
||
| 947 | 947 | function SetX($x) |
| 948 | 948 | { |
| 949 | 949 | // Set x position |
| 950 | - if($x>=0) |
|
| 950 | + if ($x >= 0) |
|
| 951 | 951 | $this->x = $x; |
| 952 | 952 | else |
| 953 | - $this->x = $this->w+$x; |
|
| 953 | + $this->x = $this->w + $x; |
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | function GetY() |
@@ -959,14 +959,14 @@ discard block |
||
| 959 | 959 | return $this->y; |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | -function SetY($y, $resetX=true) |
|
| 962 | +function SetY($y, $resetX = true) |
|
| 963 | 963 | { |
| 964 | 964 | // Set y position and optionally reset x |
| 965 | - if($y>=0) |
|
| 965 | + if ($y >= 0) |
|
| 966 | 966 | $this->y = $y; |
| 967 | 967 | else |
| 968 | - $this->y = $this->h+$y; |
|
| 969 | - if($resetX) |
|
| 968 | + $this->y = $this->h + $y; |
|
| 969 | + if ($resetX) |
|
| 970 | 970 | $this->x = $this->lMargin; |
| 971 | 971 | } |
| 972 | 972 | |
@@ -974,34 +974,34 @@ discard block |
||
| 974 | 974 | { |
| 975 | 975 | // Set x and y positions |
| 976 | 976 | $this->SetX($x); |
| 977 | - $this->SetY($y,false); |
|
| 977 | + $this->SetY($y, false); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | -function Output($dest='', $name='', $isUTF8=false) |
|
| 980 | +function Output($dest = '', $name = '', $isUTF8 = false) |
|
| 981 | 981 | { |
| 982 | 982 | // Output PDF to some destination |
| 983 | 983 | $this->Close(); |
| 984 | - if(strlen($name)==1 && strlen($dest)!=1) |
|
| 984 | + if (strlen($name) == 1 && strlen($dest) != 1) |
|
| 985 | 985 | { |
| 986 | 986 | // Fix parameter order |
| 987 | 987 | $tmp = $dest; |
| 988 | 988 | $dest = $name; |
| 989 | 989 | $name = $tmp; |
| 990 | 990 | } |
| 991 | - if($dest=='') |
|
| 991 | + if ($dest == '') |
|
| 992 | 992 | $dest = 'I'; |
| 993 | - if($name=='') |
|
| 993 | + if ($name == '') |
|
| 994 | 994 | $name = 'doc.pdf'; |
| 995 | - switch(strtoupper($dest)) |
|
| 995 | + switch (strtoupper($dest)) |
|
| 996 | 996 | { |
| 997 | 997 | case 'I': |
| 998 | 998 | // Send to standard output |
| 999 | 999 | $this->_checkoutput(); |
| 1000 | - if(PHP_SAPI!='cli') |
|
| 1000 | + if (PHP_SAPI != 'cli') |
|
| 1001 | 1001 | { |
| 1002 | 1002 | // We send to a browser |
| 1003 | 1003 | header('Content-Type: application/pdf'); |
| 1004 | - header('Content-Disposition: inline; '.$this->_httpencode('filename',$name,$isUTF8)); |
|
| 1004 | + header('Content-Disposition: inline; '.$this->_httpencode('filename', $name, $isUTF8)); |
|
| 1005 | 1005 | header('Cache-Control: private, max-age=0, must-revalidate'); |
| 1006 | 1006 | header('Pragma: public'); |
| 1007 | 1007 | } |
@@ -1011,14 +1011,14 @@ discard block |
||
| 1011 | 1011 | // Download file |
| 1012 | 1012 | $this->_checkoutput(); |
| 1013 | 1013 | header('Content-Type: application/x-download'); |
| 1014 | - header('Content-Disposition: attachment; '.$this->_httpencode('filename',$name,$isUTF8)); |
|
| 1014 | + header('Content-Disposition: attachment; '.$this->_httpencode('filename', $name, $isUTF8)); |
|
| 1015 | 1015 | header('Cache-Control: private, max-age=0, must-revalidate'); |
| 1016 | 1016 | header('Pragma: public'); |
| 1017 | 1017 | echo $this->buffer; |
| 1018 | 1018 | break; |
| 1019 | 1019 | case 'F': |
| 1020 | 1020 | // Save to local file |
| 1021 | - if(!file_put_contents($name,$this->buffer)) |
|
| 1021 | + if (!file_put_contents($name, $this->buffer)) |
|
| 1022 | 1022 | $this->Error('Unable to create output file: '.$name); |
| 1023 | 1023 | break; |
| 1024 | 1024 | case 'S': |
@@ -1037,21 +1037,21 @@ discard block |
||
| 1037 | 1037 | protected function _dochecks() |
| 1038 | 1038 | { |
| 1039 | 1039 | // Check mbstring overloading |
| 1040 | - if(ini_get('mbstring.func_overload') & 2) |
|
| 1040 | + if (ini_get('mbstring.func_overload') & 2) |
|
| 1041 | 1041 | $this->Error('mbstring overloading must be disabled'); |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | protected function _checkoutput() |
| 1045 | 1045 | { |
| 1046 | - if(PHP_SAPI!='cli') |
|
| 1046 | + if (PHP_SAPI != 'cli') |
|
| 1047 | 1047 | { |
| 1048 | - if(headers_sent($file,$line)) |
|
| 1048 | + if (headers_sent($file, $line)) |
|
| 1049 | 1049 | $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
| 1050 | 1050 | } |
| 1051 | - if(ob_get_length()) |
|
| 1051 | + if (ob_get_length()) |
|
| 1052 | 1052 | { |
| 1053 | 1053 | // The output buffer is not empty |
| 1054 | - if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents())) |
|
| 1054 | + if (preg_match('/^(\xEF\xBB\xBF)?\s*$/', ob_get_contents())) |
|
| 1055 | 1055 | { |
| 1056 | 1056 | // It contains only a UTF-8 BOM and/or whitespace, let's clean it |
| 1057 | 1057 | ob_clean(); |
@@ -1063,17 +1063,17 @@ discard block |
||
| 1063 | 1063 | |
| 1064 | 1064 | protected function _getpagesize($size) |
| 1065 | 1065 | { |
| 1066 | - if(is_string($size)) |
|
| 1066 | + if (is_string($size)) |
|
| 1067 | 1067 | { |
| 1068 | 1068 | $size = strtolower($size); |
| 1069 | - if(!isset($this->StdPageSizes[$size])) |
|
| 1069 | + if (!isset($this->StdPageSizes[$size])) |
|
| 1070 | 1070 | $this->Error('Unknown page size: '.$size); |
| 1071 | 1071 | $a = $this->StdPageSizes[$size]; |
| 1072 | - return array($a[0]/$this->k, $a[1]/$this->k); |
|
| 1072 | + return array($a[0] / $this->k, $a[1] / $this->k); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | else |
| 1075 | 1075 | { |
| 1076 | - if($size[0]>$size[1]) |
|
| 1076 | + if ($size[0] > $size[1]) |
|
| 1077 | 1077 | return array($size[1], $size[0]); |
| 1078 | 1078 | else |
| 1079 | 1079 | return $size; |
@@ -1090,18 +1090,18 @@ discard block |
||
| 1090 | 1090 | $this->y = $this->tMargin; |
| 1091 | 1091 | $this->FontFamily = ''; |
| 1092 | 1092 | // Check page size and orientation |
| 1093 | - if($orientation=='') |
|
| 1093 | + if ($orientation == '') |
|
| 1094 | 1094 | $orientation = $this->DefOrientation; |
| 1095 | 1095 | else |
| 1096 | 1096 | $orientation = strtoupper($orientation[0]); |
| 1097 | - if($size=='') |
|
| 1097 | + if ($size == '') |
|
| 1098 | 1098 | $size = $this->DefPageSize; |
| 1099 | 1099 | else |
| 1100 | 1100 | $size = $this->_getpagesize($size); |
| 1101 | - if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) |
|
| 1101 | + if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1]) |
|
| 1102 | 1102 | { |
| 1103 | 1103 | // New size or orientation |
| 1104 | - if($orientation=='P') |
|
| 1104 | + if ($orientation == 'P') |
|
| 1105 | 1105 | { |
| 1106 | 1106 | $this->w = $size[0]; |
| 1107 | 1107 | $this->h = $size[1]; |
@@ -1111,17 +1111,17 @@ discard block |
||
| 1111 | 1111 | $this->w = $size[1]; |
| 1112 | 1112 | $this->h = $size[0]; |
| 1113 | 1113 | } |
| 1114 | - $this->wPt = $this->w*$this->k; |
|
| 1115 | - $this->hPt = $this->h*$this->k; |
|
| 1116 | - $this->PageBreakTrigger = $this->h-$this->bMargin; |
|
| 1114 | + $this->wPt = $this->w * $this->k; |
|
| 1115 | + $this->hPt = $this->h * $this->k; |
|
| 1116 | + $this->PageBreakTrigger = $this->h - $this->bMargin; |
|
| 1117 | 1117 | $this->CurOrientation = $orientation; |
| 1118 | 1118 | $this->CurPageSize = $size; |
| 1119 | 1119 | } |
| 1120 | - if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) |
|
| 1120 | + if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) |
|
| 1121 | 1121 | $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
| 1122 | - if($rotation!=0) |
|
| 1122 | + if ($rotation != 0) |
|
| 1123 | 1123 | { |
| 1124 | - if($rotation%90!=0) |
|
| 1124 | + if ($rotation % 90 != 0) |
|
| 1125 | 1125 | $this->Error('Incorrect rotation value: '.$rotation); |
| 1126 | 1126 | $this->CurRotation = $rotation; |
| 1127 | 1127 | $this->PageInfo[$this->page]['rotation'] = $rotation; |
@@ -1136,14 +1136,14 @@ discard block |
||
| 1136 | 1136 | protected function _loadfont($font) |
| 1137 | 1137 | { |
| 1138 | 1138 | // Load a font definition file from the font directory |
| 1139 | - if(strpos($font,'/')!==false || strpos($font,"\\")!==false) |
|
| 1139 | + if (strpos($font, '/') !== false || strpos($font, "\\") !== false) |
|
| 1140 | 1140 | $this->Error('Incorrect font definition file name: '.$font); |
| 1141 | 1141 | include($this->fontpath.$font); |
| 1142 | - if(!isset($name)) |
|
| 1142 | + if (!isset($name)) |
|
| 1143 | 1143 | $this->Error('Could not include font definition file'); |
| 1144 | - if(isset($enc)) |
|
| 1144 | + if (isset($enc)) |
|
| 1145 | 1145 | $enc = strtolower($enc); |
| 1146 | - if(!isset($subsetted)) |
|
| 1146 | + if (!isset($subsetted)) |
|
| 1147 | 1147 | $subsetted = false; |
| 1148 | 1148 | return get_defined_vars(); |
| 1149 | 1149 | } |
@@ -1152,9 +1152,9 @@ discard block |
||
| 1152 | 1152 | { |
| 1153 | 1153 | // Test if string is ASCII |
| 1154 | 1154 | $nb = strlen($s); |
| 1155 | - for($i=0;$i<$nb;$i++) |
|
| 1155 | + for ($i = 0; $i < $nb; $i++) |
|
| 1156 | 1156 | { |
| 1157 | - if(ord($s[$i])>127) |
|
| 1157 | + if (ord($s[$i]) > 127) |
|
| 1158 | 1158 | return false; |
| 1159 | 1159 | } |
| 1160 | 1160 | return true; |
@@ -1163,11 +1163,11 @@ discard block |
||
| 1163 | 1163 | protected function _httpencode($param, $value, $isUTF8) |
| 1164 | 1164 | { |
| 1165 | 1165 | // Encode HTTP header field parameter |
| 1166 | - if($this->_isascii($value)) |
|
| 1166 | + if ($this->_isascii($value)) |
|
| 1167 | 1167 | return $param.'="'.$value.'"'; |
| 1168 | - if(!$isUTF8) |
|
| 1168 | + if (!$isUTF8) |
|
| 1169 | 1169 | $value = utf8_encode($value); |
| 1170 | - if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) |
|
| 1170 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) |
|
| 1171 | 1171 | return $param.'="'.rawurlencode($value).'"'; |
| 1172 | 1172 | else |
| 1173 | 1173 | return $param."*=UTF-8''".rawurlencode($value); |
@@ -1179,23 +1179,23 @@ discard block |
||
| 1179 | 1179 | $res = "\xFE\xFF"; |
| 1180 | 1180 | $nb = strlen($s); |
| 1181 | 1181 | $i = 0; |
| 1182 | - while($i<$nb) |
|
| 1182 | + while ($i < $nb) |
|
| 1183 | 1183 | { |
| 1184 | 1184 | $c1 = ord($s[$i++]); |
| 1185 | - if($c1>=224) |
|
| 1185 | + if ($c1 >= 224) |
|
| 1186 | 1186 | { |
| 1187 | 1187 | // 3-byte character |
| 1188 | 1188 | $c2 = ord($s[$i++]); |
| 1189 | 1189 | $c3 = ord($s[$i++]); |
| 1190 | - $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
|
| 1191 | - $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
|
| 1190 | + $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2)); |
|
| 1191 | + $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F)); |
|
| 1192 | 1192 | } |
| 1193 | - elseif($c1>=192) |
|
| 1193 | + elseif ($c1 >= 192) |
|
| 1194 | 1194 | { |
| 1195 | 1195 | // 2-byte character |
| 1196 | 1196 | $c2 = ord($s[$i++]); |
| 1197 | - $res .= chr(($c1 & 0x1C)>>2); |
|
| 1198 | - $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
|
| 1197 | + $res .= chr(($c1 & 0x1C) >> 2); |
|
| 1198 | + $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F)); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | else |
| 1201 | 1201 | { |
@@ -1209,8 +1209,8 @@ discard block |
||
| 1209 | 1209 | protected function _escape($s) |
| 1210 | 1210 | { |
| 1211 | 1211 | // Escape special characters |
| 1212 | - if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) |
|
| 1213 | - return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
| 1212 | + if (strpos($s, '(') !== false || strpos($s, ')') !== false || strpos($s, '\\') !== false || strpos($s, "\r") !== false) |
|
| 1213 | + return str_replace(array('\\', '(', ')', "\r"), array('\\\\', '\\(', '\\)', '\\r'), $s); |
|
| 1214 | 1214 | else |
| 1215 | 1215 | return $s; |
| 1216 | 1216 | } |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | protected function _textstring($s) |
| 1219 | 1219 | { |
| 1220 | 1220 | // Format a text string |
| 1221 | - if(!$this->_isascii($s)) |
|
| 1221 | + if (!$this->_isascii($s)) |
|
| 1222 | 1222 | $s = $this->_UTF8toUTF16($s); |
| 1223 | 1223 | return '('.$this->_escape($s).')'; |
| 1224 | 1224 | } |
@@ -1228,21 +1228,21 @@ discard block |
||
| 1228 | 1228 | // Underline text |
| 1229 | 1229 | $up = $this->CurrentFont['up']; |
| 1230 | 1230 | $ut = $this->CurrentFont['ut']; |
| 1231 | - $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); |
|
| 1232 | - 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); |
|
| 1231 | + $w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt, ' '); |
|
| 1232 | + 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); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | protected function _parsejpg($file) |
| 1236 | 1236 | { |
| 1237 | 1237 | // Extract info from a JPEG file |
| 1238 | 1238 | $a = getimagesize($file); |
| 1239 | - if(!$a) |
|
| 1239 | + if (!$a) |
|
| 1240 | 1240 | $this->Error('Missing or incorrect image file: '.$file); |
| 1241 | - if($a[2]!=2) |
|
| 1241 | + if ($a[2] != 2) |
|
| 1242 | 1242 | $this->Error('Not a JPEG file: '.$file); |
| 1243 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1243 | + if (!isset($a['channels']) || $a['channels'] == 3) |
|
| 1244 | 1244 | $colspace = 'DeviceRGB'; |
| 1245 | - elseif($a['channels']==4) |
|
| 1245 | + elseif ($a['channels'] == 4) |
|
| 1246 | 1246 | $colspace = 'DeviceCMYK'; |
| 1247 | 1247 | else |
| 1248 | 1248 | $colspace = 'DeviceGray'; |
@@ -1254,10 +1254,10 @@ discard block |
||
| 1254 | 1254 | protected function _parsepng($file) |
| 1255 | 1255 | { |
| 1256 | 1256 | // Extract info from a PNG file |
| 1257 | - $f = fopen($file,'rb'); |
|
| 1258 | - if(!$f) |
|
| 1257 | + $f = fopen($file, 'rb'); |
|
| 1258 | + if (!$f) |
|
| 1259 | 1259 | $this->Error('Can\'t open image file: '.$file); |
| 1260 | - $info = $this->_parsepngstream($f,$file); |
|
| 1260 | + $info = $this->_parsepngstream($f, $file); |
|
| 1261 | 1261 | fclose($f); |
| 1262 | 1262 | return $info; |
| 1263 | 1263 | } |
@@ -1265,35 +1265,35 @@ discard block |
||
| 1265 | 1265 | protected function _parsepngstream($f, $file) |
| 1266 | 1266 | { |
| 1267 | 1267 | // Check signature |
| 1268 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1268 | + if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1269 | 1269 | $this->Error('Not a PNG file: '.$file); |
| 1270 | 1270 | |
| 1271 | 1271 | // Read header chunk |
| 1272 | - $this->_readstream($f,4); |
|
| 1273 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1272 | + $this->_readstream($f, 4); |
|
| 1273 | + if ($this->_readstream($f, 4) != 'IHDR') |
|
| 1274 | 1274 | $this->Error('Incorrect PNG file: '.$file); |
| 1275 | 1275 | $w = $this->_readint($f); |
| 1276 | 1276 | $h = $this->_readint($f); |
| 1277 | - $bpc = ord($this->_readstream($f,1)); |
|
| 1278 | - if($bpc>8) |
|
| 1277 | + $bpc = ord($this->_readstream($f, 1)); |
|
| 1278 | + if ($bpc > 8) |
|
| 1279 | 1279 | $this->Error('16-bit depth not supported: '.$file); |
| 1280 | - $ct = ord($this->_readstream($f,1)); |
|
| 1281 | - if($ct==0 || $ct==4) |
|
| 1280 | + $ct = ord($this->_readstream($f, 1)); |
|
| 1281 | + if ($ct == 0 || $ct == 4) |
|
| 1282 | 1282 | $colspace = 'DeviceGray'; |
| 1283 | - elseif($ct==2 || $ct==6) |
|
| 1283 | + elseif ($ct == 2 || $ct == 6) |
|
| 1284 | 1284 | $colspace = 'DeviceRGB'; |
| 1285 | - elseif($ct==3) |
|
| 1285 | + elseif ($ct == 3) |
|
| 1286 | 1286 | $colspace = 'Indexed'; |
| 1287 | 1287 | else |
| 1288 | 1288 | $this->Error('Unknown color type: '.$file); |
| 1289 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1289 | + if (ord($this->_readstream($f, 1)) != 0) |
|
| 1290 | 1290 | $this->Error('Unknown compression method: '.$file); |
| 1291 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1291 | + if (ord($this->_readstream($f, 1)) != 0) |
|
| 1292 | 1292 | $this->Error('Unknown filter method: '.$file); |
| 1293 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1293 | + if (ord($this->_readstream($f, 1)) != 0) |
|
| 1294 | 1294 | $this->Error('Interlacing not supported: '.$file); |
| 1295 | - $this->_readstream($f,4); |
|
| 1296 | - $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
|
| 1295 | + $this->_readstream($f, 4); |
|
| 1296 | + $dp = '/Predictor 15 /Colors '.($colspace == 'DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
|
| 1297 | 1297 | |
| 1298 | 1298 | // Scan chunks looking for palette, transparency and image data |
| 1299 | 1299 | $pal = ''; |
@@ -1302,86 +1302,86 @@ discard block |
||
| 1302 | 1302 | do |
| 1303 | 1303 | { |
| 1304 | 1304 | $n = $this->_readint($f); |
| 1305 | - $type = $this->_readstream($f,4); |
|
| 1306 | - if($type=='PLTE') |
|
| 1305 | + $type = $this->_readstream($f, 4); |
|
| 1306 | + if ($type == 'PLTE') |
|
| 1307 | 1307 | { |
| 1308 | 1308 | // Read palette |
| 1309 | - $pal = $this->_readstream($f,$n); |
|
| 1310 | - $this->_readstream($f,4); |
|
| 1309 | + $pal = $this->_readstream($f, $n); |
|
| 1310 | + $this->_readstream($f, 4); |
|
| 1311 | 1311 | } |
| 1312 | - elseif($type=='tRNS') |
|
| 1312 | + elseif ($type == 'tRNS') |
|
| 1313 | 1313 | { |
| 1314 | 1314 | // Read transparency info |
| 1315 | - $t = $this->_readstream($f,$n); |
|
| 1316 | - if($ct==0) |
|
| 1317 | - $trns = array(ord(substr($t,1,1))); |
|
| 1318 | - elseif($ct==2) |
|
| 1319 | - $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1315 | + $t = $this->_readstream($f, $n); |
|
| 1316 | + if ($ct == 0) |
|
| 1317 | + $trns = array(ord(substr($t, 1, 1))); |
|
| 1318 | + elseif ($ct == 2) |
|
| 1319 | + $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1))); |
|
| 1320 | 1320 | else |
| 1321 | 1321 | { |
| 1322 | - $pos = strpos($t,chr(0)); |
|
| 1323 | - if($pos!==false) |
|
| 1322 | + $pos = strpos($t, chr(0)); |
|
| 1323 | + if ($pos !== false) |
|
| 1324 | 1324 | $trns = array($pos); |
| 1325 | 1325 | } |
| 1326 | - $this->_readstream($f,4); |
|
| 1326 | + $this->_readstream($f, 4); |
|
| 1327 | 1327 | } |
| 1328 | - elseif($type=='IDAT') |
|
| 1328 | + elseif ($type == 'IDAT') |
|
| 1329 | 1329 | { |
| 1330 | 1330 | // Read image data block |
| 1331 | - $data .= $this->_readstream($f,$n); |
|
| 1332 | - $this->_readstream($f,4); |
|
| 1331 | + $data .= $this->_readstream($f, $n); |
|
| 1332 | + $this->_readstream($f, 4); |
|
| 1333 | 1333 | } |
| 1334 | - elseif($type=='IEND') |
|
| 1334 | + elseif ($type == 'IEND') |
|
| 1335 | 1335 | break; |
| 1336 | 1336 | else |
| 1337 | - $this->_readstream($f,$n+4); |
|
| 1337 | + $this->_readstream($f, $n + 4); |
|
| 1338 | 1338 | } |
| 1339 | - while($n); |
|
| 1339 | + while ($n); |
|
| 1340 | 1340 | |
| 1341 | - if($colspace=='Indexed' && empty($pal)) |
|
| 1341 | + if ($colspace == 'Indexed' && empty($pal)) |
|
| 1342 | 1342 | $this->Error('Missing palette in '.$file); |
| 1343 | 1343 | $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); |
| 1344 | - if($ct>=4) |
|
| 1344 | + if ($ct >= 4) |
|
| 1345 | 1345 | { |
| 1346 | 1346 | // Extract alpha channel |
| 1347 | - if(!function_exists('gzuncompress')) |
|
| 1347 | + if (!function_exists('gzuncompress')) |
|
| 1348 | 1348 | $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
| 1349 | 1349 | $data = gzuncompress($data); |
| 1350 | 1350 | $color = ''; |
| 1351 | 1351 | $alpha = ''; |
| 1352 | - if($ct==4) |
|
| 1352 | + if ($ct == 4) |
|
| 1353 | 1353 | { |
| 1354 | 1354 | // Gray image |
| 1355 | - $len = 2*$w; |
|
| 1356 | - for($i=0;$i<$h;$i++) |
|
| 1355 | + $len = 2 * $w; |
|
| 1356 | + for ($i = 0; $i < $h; $i++) |
|
| 1357 | 1357 | { |
| 1358 | - $pos = (1+$len)*$i; |
|
| 1358 | + $pos = (1 + $len) * $i; |
|
| 1359 | 1359 | $color .= $data[$pos]; |
| 1360 | 1360 | $alpha .= $data[$pos]; |
| 1361 | - $line = substr($data,$pos+1,$len); |
|
| 1362 | - $color .= preg_replace('/(.)./s','$1',$line); |
|
| 1363 | - $alpha .= preg_replace('/.(.)/s','$1',$line); |
|
| 1361 | + $line = substr($data, $pos + 1, $len); |
|
| 1362 | + $color .= preg_replace('/(.)./s', '$1', $line); |
|
| 1363 | + $alpha .= preg_replace('/.(.)/s', '$1', $line); |
|
| 1364 | 1364 | } |
| 1365 | 1365 | } |
| 1366 | 1366 | else |
| 1367 | 1367 | { |
| 1368 | 1368 | // RGB image |
| 1369 | - $len = 4*$w; |
|
| 1370 | - for($i=0;$i<$h;$i++) |
|
| 1369 | + $len = 4 * $w; |
|
| 1370 | + for ($i = 0; $i < $h; $i++) |
|
| 1371 | 1371 | { |
| 1372 | - $pos = (1+$len)*$i; |
|
| 1372 | + $pos = (1 + $len) * $i; |
|
| 1373 | 1373 | $color .= $data[$pos]; |
| 1374 | 1374 | $alpha .= $data[$pos]; |
| 1375 | - $line = substr($data,$pos+1,$len); |
|
| 1376 | - $color .= preg_replace('/(.{3})./s','$1',$line); |
|
| 1377 | - $alpha .= preg_replace('/.{3}(.)/s','$1',$line); |
|
| 1375 | + $line = substr($data, $pos + 1, $len); |
|
| 1376 | + $color .= preg_replace('/(.{3})./s', '$1', $line); |
|
| 1377 | + $alpha .= preg_replace('/.{3}(.)/s', '$1', $line); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | } |
| 1380 | 1380 | unset($data); |
| 1381 | 1381 | $data = gzcompress($color); |
| 1382 | 1382 | $info['smask'] = gzcompress($alpha); |
| 1383 | 1383 | $this->WithAlpha = true; |
| 1384 | - if($this->PDFVersion<'1.4') |
|
| 1384 | + if ($this->PDFVersion < '1.4') |
|
| 1385 | 1385 | $this->PDFVersion = '1.4'; |
| 1386 | 1386 | } |
| 1387 | 1387 | $info['data'] = $data; |
@@ -1392,15 +1392,15 @@ discard block |
||
| 1392 | 1392 | { |
| 1393 | 1393 | // Read n bytes from stream |
| 1394 | 1394 | $res = ''; |
| 1395 | - while($n>0 && !feof($f)) |
|
| 1395 | + while ($n > 0 && !feof($f)) |
|
| 1396 | 1396 | { |
| 1397 | - $s = fread($f,$n); |
|
| 1398 | - if($s===false) |
|
| 1397 | + $s = fread($f, $n); |
|
| 1398 | + if ($s === false) |
|
| 1399 | 1399 | $this->Error('Error while reading stream'); |
| 1400 | 1400 | $n -= strlen($s); |
| 1401 | 1401 | $res .= $s; |
| 1402 | 1402 | } |
| 1403 | - if($n>0) |
|
| 1403 | + if ($n > 0) |
|
| 1404 | 1404 | $this->Error('Unexpected end of stream'); |
| 1405 | 1405 | return $res; |
| 1406 | 1406 | } |
@@ -1408,31 +1408,31 @@ discard block |
||
| 1408 | 1408 | protected function _readint($f) |
| 1409 | 1409 | { |
| 1410 | 1410 | // Read a 4-byte integer from stream |
| 1411 | - $a = unpack('Ni',$this->_readstream($f,4)); |
|
| 1411 | + $a = unpack('Ni', $this->_readstream($f, 4)); |
|
| 1412 | 1412 | return $a['i']; |
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | 1415 | protected function _parsegif($file) |
| 1416 | 1416 | { |
| 1417 | 1417 | // Extract info from a GIF file (via PNG conversion) |
| 1418 | - if(!function_exists('imagepng')) |
|
| 1418 | + if (!function_exists('imagepng')) |
|
| 1419 | 1419 | $this->Error('GD extension is required for GIF support'); |
| 1420 | - if(!function_exists('imagecreatefromgif')) |
|
| 1420 | + if (!function_exists('imagecreatefromgif')) |
|
| 1421 | 1421 | $this->Error('GD has no GIF read support'); |
| 1422 | 1422 | $im = imagecreatefromgif($file); |
| 1423 | - if(!$im) |
|
| 1423 | + if (!$im) |
|
| 1424 | 1424 | $this->Error('Missing or incorrect image file: '.$file); |
| 1425 | - imageinterlace($im,0); |
|
| 1425 | + imageinterlace($im, 0); |
|
| 1426 | 1426 | ob_start(); |
| 1427 | 1427 | imagepng($im); |
| 1428 | 1428 | $data = ob_get_clean(); |
| 1429 | 1429 | imagedestroy($im); |
| 1430 | - $f = fopen('php://temp','rb+'); |
|
| 1431 | - if(!$f) |
|
| 1430 | + $f = fopen('php://temp', 'rb+'); |
|
| 1431 | + if (!$f) |
|
| 1432 | 1432 | $this->Error('Unable to create memory stream'); |
| 1433 | - fwrite($f,$data); |
|
| 1433 | + fwrite($f, $data); |
|
| 1434 | 1434 | rewind($f); |
| 1435 | - $info = $this->_parsepngstream($f,$file); |
|
| 1435 | + $info = $this->_parsepngstream($f, $file); |
|
| 1436 | 1436 | fclose($f); |
| 1437 | 1437 | return $info; |
| 1438 | 1438 | } |
@@ -1440,13 +1440,13 @@ discard block |
||
| 1440 | 1440 | protected function _out($s) |
| 1441 | 1441 | { |
| 1442 | 1442 | // Add a line to the document |
| 1443 | - if($this->state==2) |
|
| 1443 | + if ($this->state == 2) |
|
| 1444 | 1444 | $this->pages[$this->page] .= $s."\n"; |
| 1445 | - elseif($this->state==1) |
|
| 1445 | + elseif ($this->state == 1) |
|
| 1446 | 1446 | $this->_put($s); |
| 1447 | - elseif($this->state==0) |
|
| 1447 | + elseif ($this->state == 0) |
|
| 1448 | 1448 | $this->Error('No page has been added yet'); |
| 1449 | - elseif($this->state==3) |
|
| 1449 | + elseif ($this->state == 3) |
|
| 1450 | 1450 | $this->Error('The document is closed'); |
| 1451 | 1451 | } |
| 1452 | 1452 | |
@@ -1460,10 +1460,10 @@ discard block |
||
| 1460 | 1460 | return strlen($this->buffer); |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | -protected function _newobj($n=null) |
|
| 1463 | +protected function _newobj($n = null) |
|
| 1464 | 1464 | { |
| 1465 | 1465 | // Begin a new object |
| 1466 | - if($n===null) |
|
| 1466 | + if ($n === null) |
|
| 1467 | 1467 | $n = ++$this->n; |
| 1468 | 1468 | $this->offsets[$n] = $this->_getoffset(); |
| 1469 | 1469 | $this->_put($n.' 0 obj'); |
@@ -1478,7 +1478,7 @@ discard block |
||
| 1478 | 1478 | |
| 1479 | 1479 | protected function _putstreamobject($data) |
| 1480 | 1480 | { |
| 1481 | - if($this->compress) |
|
| 1481 | + if ($this->compress) |
|
| 1482 | 1482 | { |
| 1483 | 1483 | $entries = '/Filter /FlateDecode '; |
| 1484 | 1484 | $data = gzcompress($data); |
@@ -1497,42 +1497,42 @@ discard block |
||
| 1497 | 1497 | $this->_newobj(); |
| 1498 | 1498 | $this->_put('<</Type /Page'); |
| 1499 | 1499 | $this->_put('/Parent 1 0 R'); |
| 1500 | - if(isset($this->PageInfo[$n]['size'])) |
|
| 1501 | - $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); |
|
| 1502 | - if(isset($this->PageInfo[$n]['rotation'])) |
|
| 1500 | + if (isset($this->PageInfo[$n]['size'])) |
|
| 1501 | + $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageInfo[$n]['size'][0], $this->PageInfo[$n]['size'][1])); |
|
| 1502 | + if (isset($this->PageInfo[$n]['rotation'])) |
|
| 1503 | 1503 | $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); |
| 1504 | 1504 | $this->_put('/Resources 2 0 R'); |
| 1505 | - if(!empty($this->PageLinks[$n])) |
|
| 1505 | + if (!empty($this->PageLinks[$n])) |
|
| 1506 | 1506 | { |
| 1507 | 1507 | $s = '/Annots ['; |
| 1508 | - foreach($this->PageLinks[$n] as $pl) |
|
| 1508 | + foreach ($this->PageLinks[$n] as $pl) |
|
| 1509 | 1509 | $s .= $pl[5].' 0 R '; |
| 1510 | 1510 | $s .= ']'; |
| 1511 | 1511 | $this->_put($s); |
| 1512 | 1512 | } |
| 1513 | - if($this->WithAlpha) |
|
| 1513 | + if ($this->WithAlpha) |
|
| 1514 | 1514 | $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
| 1515 | - $this->_put('/Contents '.($this->n+1).' 0 R>>'); |
|
| 1515 | + $this->_put('/Contents '.($this->n + 1).' 0 R>>'); |
|
| 1516 | 1516 | $this->_put('endobj'); |
| 1517 | 1517 | // Page content |
| 1518 | - if(!empty($this->AliasNbPages)) |
|
| 1519 | - $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); |
|
| 1518 | + if (!empty($this->AliasNbPages)) |
|
| 1519 | + $this->pages[$n] = str_replace($this->AliasNbPages, $this->page, $this->pages[$n]); |
|
| 1520 | 1520 | $this->_putstreamobject($this->pages[$n]); |
| 1521 | 1521 | // Annotations |
| 1522 | - foreach($this->PageLinks[$n] as $pl) |
|
| 1522 | + foreach ($this->PageLinks[$n] as $pl) |
|
| 1523 | 1523 | { |
| 1524 | - $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
|
| 1524 | + $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]); |
|
| 1525 | 1525 | $s = '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
| 1526 | - if(is_string($pl[4])) |
|
| 1526 | + if (is_string($pl[4])) |
|
| 1527 | 1527 | $s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
| 1528 | 1528 | else |
| 1529 | 1529 | { |
| 1530 | 1530 | $l = $this->links[$pl[4]]; |
| 1531 | - if(isset($this->PageInfo[$l[0]]['size'])) |
|
| 1531 | + if (isset($this->PageInfo[$l[0]]['size'])) |
|
| 1532 | 1532 | $h = $this->PageInfo[$l[0]]['size'][1]; |
| 1533 | 1533 | else |
| 1534 | - $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 1535 | - $s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); |
|
| 1534 | + $h = ($this->DefOrientation == 'P') ? $this->DefPageSize[1] * $this->k : $this->DefPageSize[0] * $this->k; |
|
| 1535 | + $s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', $this->PageInfo[$l[0]]['n'], $h - $l[1] * $this->k); |
|
| 1536 | 1536 | } |
| 1537 | 1537 | $this->_newobj(); |
| 1538 | 1538 | $this->_put($s); |
@@ -1544,26 +1544,26 @@ discard block |
||
| 1544 | 1544 | { |
| 1545 | 1545 | $nb = $this->page; |
| 1546 | 1546 | $n = $this->n; |
| 1547 | - for($i=1;$i<=$nb;$i++) |
|
| 1547 | + for ($i = 1; $i <= $nb; $i++) |
|
| 1548 | 1548 | { |
| 1549 | 1549 | $this->PageInfo[$i]['n'] = ++$n; |
| 1550 | 1550 | $n++; |
| 1551 | - foreach($this->PageLinks[$i] as &$pl) |
|
| 1551 | + foreach ($this->PageLinks[$i] as &$pl) |
|
| 1552 | 1552 | $pl[5] = ++$n; |
| 1553 | 1553 | unset($pl); |
| 1554 | 1554 | } |
| 1555 | - for($i=1;$i<=$nb;$i++) |
|
| 1555 | + for ($i = 1; $i <= $nb; $i++) |
|
| 1556 | 1556 | $this->_putpage($i); |
| 1557 | 1557 | // Pages root |
| 1558 | 1558 | $this->_newobj(1); |
| 1559 | 1559 | $this->_put('<</Type /Pages'); |
| 1560 | 1560 | $kids = '/Kids ['; |
| 1561 | - for($i=1;$i<=$nb;$i++) |
|
| 1561 | + for ($i = 1; $i <= $nb; $i++) |
|
| 1562 | 1562 | $kids .= $this->PageInfo[$i]['n'].' 0 R '; |
| 1563 | 1563 | $kids .= ']'; |
| 1564 | 1564 | $this->_put($kids); |
| 1565 | 1565 | $this->_put('/Count '.$nb); |
| 1566 | - if($this->DefOrientation=='P') |
|
| 1566 | + if ($this->DefOrientation == 'P') |
|
| 1567 | 1567 | { |
| 1568 | 1568 | $w = $this->DefPageSize[0]; |
| 1569 | 1569 | $h = $this->DefPageSize[1]; |
@@ -1573,40 +1573,40 @@ discard block |
||
| 1573 | 1573 | $w = $this->DefPageSize[1]; |
| 1574 | 1574 | $h = $this->DefPageSize[0]; |
| 1575 | 1575 | } |
| 1576 | - $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$w*$this->k,$h*$this->k)); |
|
| 1576 | + $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]', $w * $this->k, $h * $this->k)); |
|
| 1577 | 1577 | $this->_put('>>'); |
| 1578 | 1578 | $this->_put('endobj'); |
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | protected function _putfonts() |
| 1582 | 1582 | { |
| 1583 | - foreach($this->FontFiles as $file=>$info) |
|
| 1583 | + foreach ($this->FontFiles as $file=>$info) |
|
| 1584 | 1584 | { |
| 1585 | 1585 | // Font file embedding |
| 1586 | 1586 | $this->_newobj(); |
| 1587 | 1587 | $this->FontFiles[$file]['n'] = $this->n; |
| 1588 | - $font = file_get_contents($this->fontpath.$file,true); |
|
| 1589 | - if(!$font) |
|
| 1588 | + $font = file_get_contents($this->fontpath.$file, true); |
|
| 1589 | + if (!$font) |
|
| 1590 | 1590 | $this->Error('Font file not found: '.$file); |
| 1591 | - $compressed = (substr($file,-2)=='.z'); |
|
| 1592 | - if(!$compressed && isset($info['length2'])) |
|
| 1593 | - $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); |
|
| 1591 | + $compressed = (substr($file, -2) == '.z'); |
|
| 1592 | + if (!$compressed && isset($info['length2'])) |
|
| 1593 | + $font = substr($font, 6, $info['length1']).substr($font, 6 + $info['length1'] + 6, $info['length2']); |
|
| 1594 | 1594 | $this->_put('<</Length '.strlen($font)); |
| 1595 | - if($compressed) |
|
| 1595 | + if ($compressed) |
|
| 1596 | 1596 | $this->_put('/Filter /FlateDecode'); |
| 1597 | 1597 | $this->_put('/Length1 '.$info['length1']); |
| 1598 | - if(isset($info['length2'])) |
|
| 1598 | + if (isset($info['length2'])) |
|
| 1599 | 1599 | $this->_put('/Length2 '.$info['length2'].' /Length3 0'); |
| 1600 | 1600 | $this->_put('>>'); |
| 1601 | 1601 | $this->_putstream($font); |
| 1602 | 1602 | $this->_put('endobj'); |
| 1603 | 1603 | } |
| 1604 | - foreach($this->fonts as $k=>$font) |
|
| 1604 | + foreach ($this->fonts as $k=>$font) |
|
| 1605 | 1605 | { |
| 1606 | 1606 | // Encoding |
| 1607 | - if(isset($font['diff'])) |
|
| 1607 | + if (isset($font['diff'])) |
|
| 1608 | 1608 | { |
| 1609 | - if(!isset($this->encodings[$font['enc']])) |
|
| 1609 | + if (!isset($this->encodings[$font['enc']])) |
|
| 1610 | 1610 | { |
| 1611 | 1611 | $this->_newobj(); |
| 1612 | 1612 | $this->_put('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$font['diff'].']>>'); |
@@ -1615,13 +1615,13 @@ discard block |
||
| 1615 | 1615 | } |
| 1616 | 1616 | } |
| 1617 | 1617 | // ToUnicode CMap |
| 1618 | - if(isset($font['uv'])) |
|
| 1618 | + if (isset($font['uv'])) |
|
| 1619 | 1619 | { |
| 1620 | - if(isset($font['enc'])) |
|
| 1620 | + if (isset($font['enc'])) |
|
| 1621 | 1621 | $cmapkey = $font['enc']; |
| 1622 | 1622 | else |
| 1623 | 1623 | $cmapkey = $font['name']; |
| 1624 | - if(!isset($this->cmaps[$cmapkey])) |
|
| 1624 | + if (!isset($this->cmaps[$cmapkey])) |
|
| 1625 | 1625 | { |
| 1626 | 1626 | $cmap = $this->_tounicodecmap($font['uv']); |
| 1627 | 1627 | $this->_putstreamobject($cmap); |
@@ -1629,26 +1629,26 @@ discard block |
||
| 1629 | 1629 | } |
| 1630 | 1630 | } |
| 1631 | 1631 | // Font object |
| 1632 | - $this->fonts[$k]['n'] = $this->n+1; |
|
| 1632 | + $this->fonts[$k]['n'] = $this->n + 1; |
|
| 1633 | 1633 | $type = $font['type']; |
| 1634 | 1634 | $name = $font['name']; |
| 1635 | - if($font['subsetted']) |
|
| 1635 | + if ($font['subsetted']) |
|
| 1636 | 1636 | $name = 'AAAAAA+'.$name; |
| 1637 | - if($type=='Core') |
|
| 1637 | + if ($type == 'Core') |
|
| 1638 | 1638 | { |
| 1639 | 1639 | // Core font |
| 1640 | 1640 | $this->_newobj(); |
| 1641 | 1641 | $this->_put('<</Type /Font'); |
| 1642 | 1642 | $this->_put('/BaseFont /'.$name); |
| 1643 | 1643 | $this->_put('/Subtype /Type1'); |
| 1644 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1644 | + if ($name != 'Symbol' && $name != 'ZapfDingbats') |
|
| 1645 | 1645 | $this->_put('/Encoding /WinAnsiEncoding'); |
| 1646 | - if(isset($font['uv'])) |
|
| 1646 | + if (isset($font['uv'])) |
|
| 1647 | 1647 | $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
| 1648 | 1648 | $this->_put('>>'); |
| 1649 | 1649 | $this->_put('endobj'); |
| 1650 | 1650 | } |
| 1651 | - elseif($type=='Type1' || $type=='TrueType') |
|
| 1651 | + elseif ($type == 'Type1' || $type == 'TrueType') |
|
| 1652 | 1652 | { |
| 1653 | 1653 | // Additional Type1 or TrueType/OpenType font |
| 1654 | 1654 | $this->_newobj(); |
@@ -1656,13 +1656,13 @@ discard block |
||
| 1656 | 1656 | $this->_put('/BaseFont /'.$name); |
| 1657 | 1657 | $this->_put('/Subtype /'.$type); |
| 1658 | 1658 | $this->_put('/FirstChar 32 /LastChar 255'); |
| 1659 | - $this->_put('/Widths '.($this->n+1).' 0 R'); |
|
| 1660 | - $this->_put('/FontDescriptor '.($this->n+2).' 0 R'); |
|
| 1661 | - if(isset($font['diff'])) |
|
| 1659 | + $this->_put('/Widths '.($this->n + 1).' 0 R'); |
|
| 1660 | + $this->_put('/FontDescriptor '.($this->n + 2).' 0 R'); |
|
| 1661 | + if (isset($font['diff'])) |
|
| 1662 | 1662 | $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); |
| 1663 | 1663 | else |
| 1664 | 1664 | $this->_put('/Encoding /WinAnsiEncoding'); |
| 1665 | - if(isset($font['uv'])) |
|
| 1665 | + if (isset($font['uv'])) |
|
| 1666 | 1666 | $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
| 1667 | 1667 | $this->_put('>>'); |
| 1668 | 1668 | $this->_put('endobj'); |
@@ -1670,17 +1670,17 @@ discard block |
||
| 1670 | 1670 | $this->_newobj(); |
| 1671 | 1671 | $cw = &$font['cw']; |
| 1672 | 1672 | $s = '['; |
| 1673 | - for($i=32;$i<=255;$i++) |
|
| 1673 | + for ($i = 32; $i <= 255; $i++) |
|
| 1674 | 1674 | $s .= $cw[chr($i)].' '; |
| 1675 | 1675 | $this->_put($s.']'); |
| 1676 | 1676 | $this->_put('endobj'); |
| 1677 | 1677 | // Descriptor |
| 1678 | 1678 | $this->_newobj(); |
| 1679 | 1679 | $s = '<</Type /FontDescriptor /FontName /'.$name; |
| 1680 | - foreach($font['desc'] as $k=>$v) |
|
| 1680 | + foreach ($font['desc'] as $k=>$v) |
|
| 1681 | 1681 | $s .= ' /'.$k.' '.$v; |
| 1682 | - if(!empty($font['file'])) |
|
| 1683 | - $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1682 | + if (!empty($font['file'])) |
|
| 1683 | + $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1684 | 1684 | $this->_put($s.'>>'); |
| 1685 | 1685 | $this->_put('endobj'); |
| 1686 | 1686 | } |
@@ -1688,7 +1688,7 @@ discard block |
||
| 1688 | 1688 | { |
| 1689 | 1689 | // Allow for additional types |
| 1690 | 1690 | $mtd = '_put'.strtolower($type); |
| 1691 | - if(!method_exists($this,$mtd)) |
|
| 1691 | + if (!method_exists($this, $mtd)) |
|
| 1692 | 1692 | $this->Error('Unsupported font type: '.$type); |
| 1693 | 1693 | $this->$mtd($font); |
| 1694 | 1694 | } |
@@ -1701,16 +1701,16 @@ discard block |
||
| 1701 | 1701 | $nbr = 0; |
| 1702 | 1702 | $chars = ''; |
| 1703 | 1703 | $nbc = 0; |
| 1704 | - foreach($uv as $c=>$v) |
|
| 1704 | + foreach ($uv as $c=>$v) |
|
| 1705 | 1705 | { |
| 1706 | - if(is_array($v)) |
|
| 1706 | + if (is_array($v)) |
|
| 1707 | 1707 | { |
| 1708 | - $ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]); |
|
| 1708 | + $ranges .= sprintf("<%02X> <%02X> <%04X>\n", $c, $c + $v[1] - 1, $v[0]); |
|
| 1709 | 1709 | $nbr++; |
| 1710 | 1710 | } |
| 1711 | 1711 | else |
| 1712 | 1712 | { |
| 1713 | - $chars .= sprintf("<%02X> <%04X>\n",$c,$v); |
|
| 1713 | + $chars .= sprintf("<%02X> <%04X>\n", $c, $v); |
|
| 1714 | 1714 | $nbc++; |
| 1715 | 1715 | } |
| 1716 | 1716 | } |
@@ -1727,13 +1727,13 @@ discard block |
||
| 1727 | 1727 | $s .= "1 begincodespacerange\n"; |
| 1728 | 1728 | $s .= "<00> <FF>\n"; |
| 1729 | 1729 | $s .= "endcodespacerange\n"; |
| 1730 | - if($nbr>0) |
|
| 1730 | + if ($nbr > 0) |
|
| 1731 | 1731 | { |
| 1732 | 1732 | $s .= "$nbr beginbfrange\n"; |
| 1733 | 1733 | $s .= $ranges; |
| 1734 | 1734 | $s .= "endbfrange\n"; |
| 1735 | 1735 | } |
| 1736 | - if($nbc>0) |
|
| 1736 | + if ($nbc > 0) |
|
| 1737 | 1737 | { |
| 1738 | 1738 | $s .= "$nbc beginbfchar\n"; |
| 1739 | 1739 | $s .= $chars; |
@@ -1748,7 +1748,7 @@ discard block |
||
| 1748 | 1748 | |
| 1749 | 1749 | protected function _putimages() |
| 1750 | 1750 | { |
| 1751 | - foreach(array_keys($this->images) as $file) |
|
| 1751 | + foreach (array_keys($this->images) as $file) |
|
| 1752 | 1752 | { |
| 1753 | 1753 | $this->_putimage($this->images[$file]); |
| 1754 | 1754 | unset($this->images[$file]['data']); |
@@ -1764,46 +1764,46 @@ discard block |
||
| 1764 | 1764 | $this->_put('/Subtype /Image'); |
| 1765 | 1765 | $this->_put('/Width '.$info['w']); |
| 1766 | 1766 | $this->_put('/Height '.$info['h']); |
| 1767 | - if($info['cs']=='Indexed') |
|
| 1768 | - $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1767 | + if ($info['cs'] == 'Indexed') |
|
| 1768 | + $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]'); |
|
| 1769 | 1769 | else |
| 1770 | 1770 | { |
| 1771 | 1771 | $this->_put('/ColorSpace /'.$info['cs']); |
| 1772 | - if($info['cs']=='DeviceCMYK') |
|
| 1772 | + if ($info['cs'] == 'DeviceCMYK') |
|
| 1773 | 1773 | $this->_put('/Decode [1 0 1 0 1 0 1 0]'); |
| 1774 | 1774 | } |
| 1775 | 1775 | $this->_put('/BitsPerComponent '.$info['bpc']); |
| 1776 | - if(isset($info['f'])) |
|
| 1776 | + if (isset($info['f'])) |
|
| 1777 | 1777 | $this->_put('/Filter /'.$info['f']); |
| 1778 | - if(isset($info['dp'])) |
|
| 1778 | + if (isset($info['dp'])) |
|
| 1779 | 1779 | $this->_put('/DecodeParms <<'.$info['dp'].'>>'); |
| 1780 | - if(isset($info['trns']) && is_array($info['trns'])) |
|
| 1780 | + if (isset($info['trns']) && is_array($info['trns'])) |
|
| 1781 | 1781 | { |
| 1782 | 1782 | $trns = ''; |
| 1783 | - for($i=0;$i<count($info['trns']);$i++) |
|
| 1783 | + for ($i = 0; $i < count($info['trns']); $i++) |
|
| 1784 | 1784 | $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
| 1785 | 1785 | $this->_put('/Mask ['.$trns.']'); |
| 1786 | 1786 | } |
| 1787 | - if(isset($info['smask'])) |
|
| 1788 | - $this->_put('/SMask '.($this->n+1).' 0 R'); |
|
| 1787 | + if (isset($info['smask'])) |
|
| 1788 | + $this->_put('/SMask '.($this->n + 1).' 0 R'); |
|
| 1789 | 1789 | $this->_put('/Length '.strlen($info['data']).'>>'); |
| 1790 | 1790 | $this->_putstream($info['data']); |
| 1791 | 1791 | $this->_put('endobj'); |
| 1792 | 1792 | // Soft mask |
| 1793 | - if(isset($info['smask'])) |
|
| 1793 | + if (isset($info['smask'])) |
|
| 1794 | 1794 | { |
| 1795 | 1795 | $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w']; |
| 1796 | 1796 | $smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']); |
| 1797 | 1797 | $this->_putimage($smask); |
| 1798 | 1798 | } |
| 1799 | 1799 | // Palette |
| 1800 | - if($info['cs']=='Indexed') |
|
| 1800 | + if ($info['cs'] == 'Indexed') |
|
| 1801 | 1801 | $this->_putstreamobject($info['pal']); |
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | protected function _putxobjectdict() |
| 1805 | 1805 | { |
| 1806 | - foreach($this->images as $image) |
|
| 1806 | + foreach ($this->images as $image) |
|
| 1807 | 1807 | $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); |
| 1808 | 1808 | } |
| 1809 | 1809 | |
@@ -1811,7 +1811,7 @@ discard block |
||
| 1811 | 1811 | { |
| 1812 | 1812 | $this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 1813 | 1813 | $this->_put('/Font <<'); |
| 1814 | - foreach($this->fonts as $font) |
|
| 1814 | + foreach ($this->fonts as $font) |
|
| 1815 | 1815 | $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); |
| 1816 | 1816 | $this->_put('>>'); |
| 1817 | 1817 | $this->_put('/XObject <<'); |
@@ -1835,7 +1835,7 @@ discard block |
||
| 1835 | 1835 | { |
| 1836 | 1836 | $this->metadata['Producer'] = 'FPDF '.FPDF_VERSION; |
| 1837 | 1837 | $this->metadata['CreationDate'] = 'D:'.@date('YmdHis'); |
| 1838 | - foreach($this->metadata as $key=>$value) |
|
| 1838 | + foreach ($this->metadata as $key=>$value) |
|
| 1839 | 1839 | $this->_put('/'.$key.' '.$this->_textstring($value)); |
| 1840 | 1840 | } |
| 1841 | 1841 | |
@@ -1844,19 +1844,19 @@ discard block |
||
| 1844 | 1844 | $n = $this->PageInfo[1]['n']; |
| 1845 | 1845 | $this->_put('/Type /Catalog'); |
| 1846 | 1846 | $this->_put('/Pages 1 0 R'); |
| 1847 | - if($this->ZoomMode=='fullpage') |
|
| 1847 | + if ($this->ZoomMode == 'fullpage') |
|
| 1848 | 1848 | $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); |
| 1849 | - elseif($this->ZoomMode=='fullwidth') |
|
| 1849 | + elseif ($this->ZoomMode == 'fullwidth') |
|
| 1850 | 1850 | $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); |
| 1851 | - elseif($this->ZoomMode=='real') |
|
| 1851 | + elseif ($this->ZoomMode == 'real') |
|
| 1852 | 1852 | $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); |
| 1853 | - elseif(!is_string($this->ZoomMode)) |
|
| 1854 | - $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); |
|
| 1855 | - if($this->LayoutMode=='single') |
|
| 1853 | + elseif (!is_string($this->ZoomMode)) |
|
| 1854 | + $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']'); |
|
| 1855 | + if ($this->LayoutMode == 'single') |
|
| 1856 | 1856 | $this->_put('/PageLayout /SinglePage'); |
| 1857 | - elseif($this->LayoutMode=='continuous') |
|
| 1857 | + elseif ($this->LayoutMode == 'continuous') |
|
| 1858 | 1858 | $this->_put('/PageLayout /OneColumn'); |
| 1859 | - elseif($this->LayoutMode=='two') |
|
| 1859 | + elseif ($this->LayoutMode == 'two') |
|
| 1860 | 1860 | $this->_put('/PageLayout /TwoColumnLeft'); |
| 1861 | 1861 | } |
| 1862 | 1862 | |
@@ -1867,9 +1867,9 @@ discard block |
||
| 1867 | 1867 | |
| 1868 | 1868 | protected function _puttrailer() |
| 1869 | 1869 | { |
| 1870 | - $this->_put('/Size '.($this->n+1)); |
|
| 1870 | + $this->_put('/Size '.($this->n + 1)); |
|
| 1871 | 1871 | $this->_put('/Root '.$this->n.' 0 R'); |
| 1872 | - $this->_put('/Info '.($this->n-1).' 0 R'); |
|
| 1872 | + $this->_put('/Info '.($this->n - 1).' 0 R'); |
|
| 1873 | 1873 | } |
| 1874 | 1874 | |
| 1875 | 1875 | protected function _enddoc() |
@@ -1892,10 +1892,10 @@ discard block |
||
| 1892 | 1892 | // Cross-ref |
| 1893 | 1893 | $offset = $this->_getoffset(); |
| 1894 | 1894 | $this->_put('xref'); |
| 1895 | - $this->_put('0 '.($this->n+1)); |
|
| 1895 | + $this->_put('0 '.($this->n + 1)); |
|
| 1896 | 1896 | $this->_put('0000000000 65535 f '); |
| 1897 | - for($i=1;$i<=$this->n;$i++) |
|
| 1898 | - $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1897 | + for ($i = 1; $i <= $this->n; $i++) |
|
| 1898 | + $this->_put(sprintf('%010d 00000 n ', $this->offsets[$i])); |
|
| 1899 | 1899 | // Trailer |
| 1900 | 1900 | $this->_put('trailer'); |
| 1901 | 1901 | $this->_put('<<'); |
@@ -105,26 +105,28 @@ discard block |
||
| 105 | 105 | if(defined('FPDF_FONTPATH')) |
| 106 | 106 | { |
| 107 | 107 | $this->fontpath = FPDF_FONTPATH; |
| 108 | - if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') |
|
| 109 | - $this->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 = ''; |
|
| 110 | 115 | } |
| 111 | - elseif(is_dir(dirname(__FILE__).'/font')) |
|
| 112 | - $this->fontpath = dirname(__FILE__).'/font/'; |
|
| 113 | - else |
|
| 114 | - $this->fontpath = ''; |
|
| 115 | 116 | // Core fonts |
| 116 | 117 | $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats','verdana','calligra','Arimo-Regular'); |
| 117 | 118 | // 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); |
|
| 119 | + if($unit=='pt') { |
|
| 120 | + $this->k = 1; |
|
| 121 | + } elseif($unit=='mm') { |
|
| 122 | + $this->k = 72/25.4; |
|
| 123 | + } elseif($unit=='cm') { |
|
| 124 | + $this->k = 72/2.54; |
|
| 125 | + } elseif($unit=='in') { |
|
| 126 | + $this->k = 72; |
|
| 127 | + } else { |
|
| 128 | + $this->Error('Incorrect unit: '.$unit); |
|
| 129 | + } |
|
| 128 | 130 | // Page sizes |
| 129 | 131 | $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), |
| 130 | 132 | 'letter'=>array(612,792), 'legal'=>array(612,1008)); |
@@ -138,15 +140,14 @@ discard block |
||
| 138 | 140 | $this->DefOrientation = 'P'; |
| 139 | 141 | $this->w = $size[0]; |
| 140 | 142 | $this->h = $size[1]; |
| 141 | - } |
|
| 142 | - elseif($orientation=='l' || $orientation=='landscape') |
|
| 143 | + } elseif($orientation=='l' || $orientation=='landscape') |
|
| 143 | 144 | { |
| 144 | 145 | $this->DefOrientation = 'L'; |
| 145 | 146 | $this->w = $size[1]; |
| 146 | 147 | $this->h = $size[0]; |
| 148 | + } else { |
|
| 149 | + $this->Error('Incorrect orientation: '.$orientation); |
|
| 147 | 150 | } |
| 148 | - else |
|
| 149 | - $this->Error('Incorrect orientation: '.$orientation); |
|
| 150 | 151 | $this->CurOrientation = $this->DefOrientation; |
| 151 | 152 | $this->wPt = $this->w*$this->k; |
| 152 | 153 | $this->hPt = $this->h*$this->k; |
@@ -174,8 +175,9 @@ discard block |
||
| 174 | 175 | // Set left, top and right margins |
| 175 | 176 | $this->lMargin = $left; |
| 176 | 177 | $this->tMargin = $top; |
| 177 | - if($right===null) |
|
| 178 | - $right = $left; |
|
| 178 | + if($right===null) { |
|
| 179 | + $right = $left; |
|
| 180 | + } |
|
| 179 | 181 | $this->rMargin = $right; |
| 180 | 182 | } |
| 181 | 183 | |
@@ -183,9 +185,10 @@ discard block |
||
| 183 | 185 | { |
| 184 | 186 | // Set left margin |
| 185 | 187 | $this->lMargin = $margin; |
| 186 | - if($this->page>0 && $this->x<$margin) |
|
| 187 | - $this->x = $margin; |
|
| 188 | -} |
|
| 188 | + if($this->page>0 && $this->x<$margin) { |
|
| 189 | + $this->x = $margin; |
|
| 190 | + } |
|
| 191 | + } |
|
| 189 | 192 | |
| 190 | 193 | function SetTopMargin($margin) |
| 191 | 194 | { |
@@ -210,24 +213,27 @@ discard block |
||
| 210 | 213 | function SetDisplayMode($zoom, $layout='default') |
| 211 | 214 | { |
| 212 | 215 | // 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 | -} |
|
| 216 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { |
|
| 217 | + $this->ZoomMode = $zoom; |
|
| 218 | + } else { |
|
| 219 | + $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 220 | + } |
|
| 221 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { |
|
| 222 | + $this->LayoutMode = $layout; |
|
| 223 | + } else { |
|
| 224 | + $this->Error('Incorrect layout display mode: '.$layout); |
|
| 225 | + } |
|
| 226 | + } |
|
| 222 | 227 | |
| 223 | 228 | function SetCompression($compress) |
| 224 | 229 | { |
| 225 | 230 | // Set page compression |
| 226 | - if(function_exists('gzcompress')) |
|
| 227 | - $this->compress = $compress; |
|
| 228 | - else |
|
| 229 | - $this->compress = false; |
|
| 230 | -} |
|
| 231 | + if(function_exists('gzcompress')) { |
|
| 232 | + $this->compress = $compress; |
|
| 233 | + } else { |
|
| 234 | + $this->compress = false; |
|
| 235 | + } |
|
| 236 | + } |
|
| 231 | 237 | |
| 232 | 238 | function SetTitle($title, $isUTF8=false) |
| 233 | 239 | { |
@@ -274,10 +280,12 @@ discard block |
||
| 274 | 280 | function Close() |
| 275 | 281 | { |
| 276 | 282 | // Terminate document |
| 277 | - if($this->state==3) |
|
| 278 | - return; |
|
| 279 | - if($this->page==0) |
|
| 280 | - $this->AddPage(); |
|
| 283 | + if($this->state==3) { |
|
| 284 | + return; |
|
| 285 | + } |
|
| 286 | + if($this->page==0) { |
|
| 287 | + $this->AddPage(); |
|
| 288 | + } |
|
| 281 | 289 | // Page footer |
| 282 | 290 | $this->InFooter = true; |
| 283 | 291 | $this->Footer(); |
@@ -291,8 +299,9 @@ discard block |
||
| 291 | 299 | function AddPage($orientation='', $size='', $rotation=0) |
| 292 | 300 | { |
| 293 | 301 | // Start a new page |
| 294 | - if($this->state==3) |
|
| 295 | - $this->Error('The document is closed'); |
|
| 302 | + if($this->state==3) { |
|
| 303 | + $this->Error('The document is closed'); |
|
| 304 | + } |
|
| 296 | 305 | $family = $this->FontFamily; |
| 297 | 306 | $style = $this->FontStyle.($this->underline ? 'U' : ''); |
| 298 | 307 | $fontsize = $this->FontSizePt; |
@@ -318,15 +327,18 @@ discard block |
||
| 318 | 327 | $this->LineWidth = $lw; |
| 319 | 328 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 320 | 329 | // Set font |
| 321 | - if($family) |
|
| 322 | - $this->SetFont($family,$style,$fontsize); |
|
| 330 | + if($family) { |
|
| 331 | + $this->SetFont($family,$style,$fontsize); |
|
| 332 | + } |
|
| 323 | 333 | // Set colors |
| 324 | 334 | $this->DrawColor = $dc; |
| 325 | - if($dc!='0 G') |
|
| 326 | - $this->_out($dc); |
|
| 335 | + if($dc!='0 G') { |
|
| 336 | + $this->_out($dc); |
|
| 337 | + } |
|
| 327 | 338 | $this->FillColor = $fc; |
| 328 | - if($fc!='0 g') |
|
| 329 | - $this->_out($fc); |
|
| 339 | + if($fc!='0 g') { |
|
| 340 | + $this->_out($fc); |
|
| 341 | + } |
|
| 330 | 342 | $this->TextColor = $tc; |
| 331 | 343 | $this->ColorFlag = $cf; |
| 332 | 344 | // Page header |
@@ -340,8 +352,9 @@ discard block |
||
| 340 | 352 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 341 | 353 | } |
| 342 | 354 | // Restore font |
| 343 | - if($family) |
|
| 344 | - $this->SetFont($family,$style,$fontsize); |
|
| 355 | + if($family) { |
|
| 356 | + $this->SetFont($family,$style,$fontsize); |
|
| 357 | + } |
|
| 345 | 358 | // Restore colors |
| 346 | 359 | if($this->DrawColor!=$dc) |
| 347 | 360 | { |
@@ -376,33 +389,38 @@ discard block |
||
| 376 | 389 | function SetDrawColor($r, $g=null, $b=null) |
| 377 | 390 | { |
| 378 | 391 | // 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 | -} |
|
| 392 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 393 | + $this->DrawColor = sprintf('%.3F G',$r/255); |
|
| 394 | + } else { |
|
| 395 | + $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 396 | + } |
|
| 397 | + if($this->page>0) { |
|
| 398 | + $this->_out($this->DrawColor); |
|
| 399 | + } |
|
| 400 | + } |
|
| 386 | 401 | |
| 387 | 402 | function SetFillColor($r, $g=null, $b=null) |
| 388 | 403 | { |
| 389 | 404 | // 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); |
|
| 405 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 406 | + $this->FillColor = sprintf('%.3F g',$r/255); |
|
| 407 | + } else { |
|
| 408 | + $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 409 | + } |
|
| 394 | 410 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
| 395 | - if($this->page>0) |
|
| 396 | - $this->_out($this->FillColor); |
|
| 397 | -} |
|
| 411 | + if($this->page>0) { |
|
| 412 | + $this->_out($this->FillColor); |
|
| 413 | + } |
|
| 414 | + } |
|
| 398 | 415 | |
| 399 | 416 | function SetTextColor($r, $g=null, $b=null) |
| 400 | 417 | { |
| 401 | 418 | // 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); |
|
| 419 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 420 | + $this->TextColor = sprintf('%.3F g',$r/255); |
|
| 421 | + } else { |
|
| 422 | + $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 423 | + } |
|
| 406 | 424 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
| 407 | 425 | } |
| 408 | 426 | |
@@ -413,8 +431,9 @@ discard block |
||
| 413 | 431 | $cw = &$this->CurrentFont['cw']; |
| 414 | 432 | $w = 0; |
| 415 | 433 | $l = strlen($s); |
| 416 | - for($i=0;$i<$l;$i++) |
|
| 417 | - $w += $cw[$s[$i]]; |
|
| 434 | + for($i=0;$i<$l;$i++) { |
|
| 435 | + $w += $cw[$s[$i]]; |
|
| 436 | + } |
|
| 418 | 437 | return $w*$this->FontSize/1000; |
| 419 | 438 | } |
| 420 | 439 | |
@@ -422,9 +441,10 @@ discard block |
||
| 422 | 441 | { |
| 423 | 442 | // Set line width |
| 424 | 443 | $this->LineWidth = $width; |
| 425 | - if($this->page>0) |
|
| 426 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 427 | -} |
|
| 444 | + if($this->page>0) { |
|
| 445 | + $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 446 | + } |
|
| 447 | + } |
|
| 428 | 448 | |
| 429 | 449 | function Line($x1, $y1, $x2, $y2) |
| 430 | 450 | { |
@@ -435,12 +455,13 @@ discard block |
||
| 435 | 455 | function Rect($x, $y, $w, $h, $style='') |
| 436 | 456 | { |
| 437 | 457 | // Draw a rectangle |
| 438 | - if($style=='F') |
|
| 439 | - $op = 'f'; |
|
| 440 | - elseif($style=='FD' || $style=='DF') |
|
| 441 | - $op = 'B'; |
|
| 442 | - else |
|
| 443 | - $op = 'S'; |
|
| 458 | + if($style=='F') { |
|
| 459 | + $op = 'f'; |
|
| 460 | + } elseif($style=='FD' || $style=='DF') { |
|
| 461 | + $op = 'B'; |
|
| 462 | + } else { |
|
| 463 | + $op = 'S'; |
|
| 464 | + } |
|
| 444 | 465 | $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 | 466 | } |
| 446 | 467 | |
@@ -448,23 +469,27 @@ discard block |
||
| 448 | 469 | { |
| 449 | 470 | // Add a TrueType, OpenType or Type1 font |
| 450 | 471 | $family = strtolower($family); |
| 451 | - if($file=='') |
|
| 452 | - $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 472 | + if($file=='') { |
|
| 473 | + $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 474 | + } |
|
| 453 | 475 | $style = strtoupper($style); |
| 454 | - if($style=='IB') |
|
| 455 | - $style = 'BI'; |
|
| 476 | + if($style=='IB') { |
|
| 477 | + $style = 'BI'; |
|
| 478 | + } |
|
| 456 | 479 | $fontkey = $family.$style; |
| 457 | - if(isset($this->fonts[$fontkey])) |
|
| 458 | - return; |
|
| 480 | + if(isset($this->fonts[$fontkey])) { |
|
| 481 | + return; |
|
| 482 | + } |
|
| 459 | 483 | $info = $this->_loadfont($file); |
| 460 | 484 | $info['i'] = count($this->fonts)+1; |
| 461 | 485 | if(!empty($info['file'])) |
| 462 | 486 | { |
| 463 | 487 | // 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']); |
|
| 488 | + if($info['type']=='TrueType') { |
|
| 489 | + $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
|
| 490 | + } else { |
|
| 491 | + $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
|
| 492 | + } |
|
| 468 | 493 | } |
| 469 | 494 | $this->fonts[$fontkey] = $info; |
| 470 | 495 | } |
@@ -472,42 +497,49 @@ discard block |
||
| 472 | 497 | function SetFont($family, $style='', $size=0) |
| 473 | 498 | { |
| 474 | 499 | // Select a font; size given in points |
| 475 | - if($family=='') |
|
| 476 | - $family = $this->FontFamily; |
|
| 477 | - else |
|
| 478 | - $family = strtolower($family); |
|
| 500 | + if($family=='') { |
|
| 501 | + $family = $this->FontFamily; |
|
| 502 | + } else { |
|
| 503 | + $family = strtolower($family); |
|
| 504 | + } |
|
| 479 | 505 | $style = strtoupper($style); |
| 480 | 506 | if(strpos($style,'U')!==false) |
| 481 | 507 | { |
| 482 | 508 | $this->underline = true; |
| 483 | 509 | $style = str_replace('U','',$style); |
| 510 | + } else { |
|
| 511 | + $this->underline = false; |
|
| 512 | + } |
|
| 513 | + if($style=='IB') { |
|
| 514 | + $style = 'BI'; |
|
| 515 | + } |
|
| 516 | + if($size==0) { |
|
| 517 | + $size = $this->FontSizePt; |
|
| 484 | 518 | } |
| 485 | - else |
|
| 486 | - $this->underline = false; |
|
| 487 | - if($style=='IB') |
|
| 488 | - $style = 'BI'; |
|
| 489 | - if($size==0) |
|
| 490 | - $size = $this->FontSizePt; |
|
| 491 | 519 | // Test if font is already selected |
| 492 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
| 493 | - return; |
|
| 520 | + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 494 | 523 | // Test if font is already loaded |
| 495 | 524 | $fontkey = $family.$style; |
| 496 | 525 | if(!isset($this->fonts[$fontkey])) |
| 497 | 526 | { |
| 498 | 527 | // Test if one of the core fonts |
| 499 | - if($family=='arial') |
|
| 500 | - $family = 'helvetica'; |
|
| 528 | + if($family=='arial') { |
|
| 529 | + $family = 'helvetica'; |
|
| 530 | + } |
|
| 501 | 531 | if(in_array($family,$this->CoreFonts)) |
| 502 | 532 | { |
| 503 | - if($family=='symbol' || $family=='zapfdingbats') |
|
| 504 | - $style = ''; |
|
| 533 | + if($family=='symbol' || $family=='zapfdingbats') { |
|
| 534 | + $style = ''; |
|
| 535 | + } |
|
| 505 | 536 | $fontkey = $family.$style; |
| 506 | - if(!isset($this->fonts[$fontkey])) |
|
| 507 | - $this->AddFont($family,$style); |
|
| 537 | + if(!isset($this->fonts[$fontkey])) { |
|
| 538 | + $this->AddFont($family,$style); |
|
| 539 | + } |
|
| 540 | + } else { |
|
| 541 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
| 508 | 542 | } |
| 509 | - else |
|
| 510 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
| 511 | 543 | } |
| 512 | 544 | // Select it |
| 513 | 545 | $this->FontFamily = $family; |
@@ -515,20 +547,23 @@ discard block |
||
| 515 | 547 | $this->FontSizePt = $size; |
| 516 | 548 | $this->FontSize = $size/$this->k; |
| 517 | 549 | $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 | -} |
|
| 550 | + if($this->page>0) { |
|
| 551 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 552 | + } |
|
| 553 | + } |
|
| 521 | 554 | |
| 522 | 555 | function SetFontSize($size) |
| 523 | 556 | { |
| 524 | 557 | // Set font size in points |
| 525 | - if($this->FontSizePt==$size) |
|
| 526 | - return; |
|
| 558 | + if($this->FontSizePt==$size) { |
|
| 559 | + return; |
|
| 560 | + } |
|
| 527 | 561 | $this->FontSizePt = $size; |
| 528 | 562 | $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 | -} |
|
| 563 | + if($this->page>0) { |
|
| 564 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 565 | + } |
|
| 566 | + } |
|
| 532 | 567 | |
| 533 | 568 | function AddLink() |
| 534 | 569 | { |
@@ -541,10 +576,12 @@ discard block |
||
| 541 | 576 | function SetLink($link, $y=0, $page=-1) |
| 542 | 577 | { |
| 543 | 578 | // Set destination of internal link |
| 544 | - if($y==-1) |
|
| 545 | - $y = $this->y; |
|
| 546 | - if($page==-1) |
|
| 547 | - $page = $this->page; |
|
| 579 | + if($y==-1) { |
|
| 580 | + $y = $this->y; |
|
| 581 | + } |
|
| 582 | + if($page==-1) { |
|
| 583 | + $page = $this->page; |
|
| 584 | + } |
|
| 548 | 585 | $this->links[$link] = array($page, $y); |
| 549 | 586 | } |
| 550 | 587 | |
@@ -557,13 +594,16 @@ discard block |
||
| 557 | 594 | function Text($x, $y, $txt) |
| 558 | 595 | { |
| 559 | 596 | // Output a string |
| 560 | - if(!isset($this->CurrentFont)) |
|
| 561 | - $this->Error('No font has been set'); |
|
| 597 | + if(!isset($this->CurrentFont)) { |
|
| 598 | + $this->Error('No font has been set'); |
|
| 599 | + } |
|
| 562 | 600 | $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'; |
|
| 601 | + if($this->underline && $txt!='') { |
|
| 602 | + $s .= ' '.$this->_dounderline($x,$y,$txt); |
|
| 603 | + } |
|
| 604 | + if($this->ColorFlag) { |
|
| 605 | + $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
| 606 | + } |
|
| 567 | 607 | $this->_out($s); |
| 568 | 608 | } |
| 569 | 609 | |
@@ -595,77 +635,94 @@ discard block |
||
| 595 | 635 | $this->_out(sprintf('%.3F Tw',$ws*$k)); |
| 596 | 636 | } |
| 597 | 637 | } |
| 598 | - if($w==0) |
|
| 599 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 638 | + if($w==0) { |
|
| 639 | + $w = $this->w-$this->rMargin-$this->x; |
|
| 640 | + } |
|
| 600 | 641 | $s = ''; |
| 601 | 642 | if($fill || $border==1) |
| 602 | 643 | { |
| 603 | - if($fill) |
|
| 604 | - $op = ($border==1) ? 'B' : 'f'; |
|
| 605 | - else |
|
| 606 | - $op = 'S'; |
|
| 644 | + if($fill) { |
|
| 645 | + $op = ($border==1) ? 'B' : 'f'; |
|
| 646 | + } else { |
|
| 647 | + $op = 'S'; |
|
| 648 | + } |
|
| 607 | 649 | $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
| 608 | 650 | } |
| 609 | 651 | if(is_string($border)) |
| 610 | 652 | { |
| 611 | 653 | $x = $this->x; |
| 612 | 654 | $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); |
|
| 655 | + if(strpos($border,'L')!==false) { |
|
| 656 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 657 | + } |
|
| 658 | + if(strpos($border,'T')!==false) { |
|
| 659 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 660 | + } |
|
| 661 | + if(strpos($border,'R')!==false) { |
|
| 662 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 663 | + } |
|
| 664 | + if(strpos($border,'B')!==false) { |
|
| 665 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 666 | + } |
|
| 621 | 667 | } |
| 622 | 668 | if($txt!=='') |
| 623 | 669 | { |
| 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.' '; |
|
| 670 | + if(!isset($this->CurrentFont)) { |
|
| 671 | + $this->Error('No font has been set'); |
|
| 672 | + } |
|
| 673 | + if($align=='R') { |
|
| 674 | + $dx = $w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 675 | + } elseif($align=='C') { |
|
| 676 | + $dx = ($w-$this->GetStringWidth($txt))/2; |
|
| 677 | + } else { |
|
| 678 | + $dx = $this->cMargin; |
|
| 679 | + } |
|
| 680 | + if($this->ColorFlag) { |
|
| 681 | + $s .= 'q '.$this->TextColor.' '; |
|
| 682 | + } |
|
| 634 | 683 | $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); |
|
| 684 | + if($this->underline) { |
|
| 685 | + $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 686 | + } |
|
| 687 | + if($this->ColorFlag) { |
|
| 688 | + $s .= ' Q'; |
|
| 689 | + } |
|
| 690 | + if($link) { |
|
| 691 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 692 | + } |
|
| 693 | + } |
|
| 694 | + if($s) { |
|
| 695 | + $this->_out($s); |
|
| 696 | + } |
|
| 644 | 697 | $this->lasth = $h; |
| 645 | 698 | if($ln>0) |
| 646 | 699 | { |
| 647 | 700 | // Go to next line |
| 648 | 701 | $this->y += $h; |
| 649 | - if($ln==1) |
|
| 650 | - $this->x = $this->lMargin; |
|
| 702 | + if($ln==1) { |
|
| 703 | + $this->x = $this->lMargin; |
|
| 704 | + } |
|
| 705 | + } else { |
|
| 706 | + $this->x += $w; |
|
| 707 | + } |
|
| 651 | 708 | } |
| 652 | - else |
|
| 653 | - $this->x += $w; |
|
| 654 | -} |
|
| 655 | 709 | |
| 656 | 710 | function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
| 657 | 711 | { |
| 658 | 712 | // Output text with automatic or explicit line breaks |
| 659 | - if(!isset($this->CurrentFont)) |
|
| 660 | - $this->Error('No font has been set'); |
|
| 713 | + if(!isset($this->CurrentFont)) { |
|
| 714 | + $this->Error('No font has been set'); |
|
| 715 | + } |
|
| 661 | 716 | $cw = &$this->CurrentFont['cw']; |
| 662 | - if($w==0) |
|
| 663 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 717 | + if($w==0) { |
|
| 718 | + $w = $this->w-$this->rMargin-$this->x; |
|
| 719 | + } |
|
| 664 | 720 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
| 665 | 721 | $s = str_replace("\r",'',$txt); |
| 666 | 722 | $nb = strlen($s); |
| 667 | - if($nb>0 && $s[$nb-1]=="\n") |
|
| 668 | - $nb--; |
|
| 723 | + if($nb>0 && $s[$nb-1]=="\n") { |
|
| 724 | + $nb--; |
|
| 725 | + } |
|
| 669 | 726 | $b = 0; |
| 670 | 727 | if($border) |
| 671 | 728 | { |
@@ -674,14 +731,15 @@ discard block |
||
| 674 | 731 | $border = 'LTRB'; |
| 675 | 732 | $b = 'LRT'; |
| 676 | 733 | $b2 = 'LR'; |
| 677 | - } |
|
| 678 | - else |
|
| 734 | + } else |
|
| 679 | 735 | { |
| 680 | 736 | $b2 = ''; |
| 681 | - if(strpos($border,'L')!==false) |
|
| 682 | - $b2 .= 'L'; |
|
| 683 | - if(strpos($border,'R')!==false) |
|
| 684 | - $b2 .= 'R'; |
|
| 737 | + if(strpos($border,'L')!==false) { |
|
| 738 | + $b2 .= 'L'; |
|
| 739 | + } |
|
| 740 | + if(strpos($border,'R')!==false) { |
|
| 741 | + $b2 .= 'R'; |
|
| 742 | + } |
|
| 685 | 743 | $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; |
| 686 | 744 | } |
| 687 | 745 | } |
@@ -710,8 +768,9 @@ discard block |
||
| 710 | 768 | $l = 0; |
| 711 | 769 | $ns = 0; |
| 712 | 770 | $nl++; |
| 713 | - if($border && $nl==2) |
|
| 714 | - $b = $b2; |
|
| 771 | + if($border && $nl==2) { |
|
| 772 | + $b = $b2; |
|
| 773 | + } |
|
| 715 | 774 | continue; |
| 716 | 775 | } |
| 717 | 776 | if($c==' ') |
@@ -726,16 +785,16 @@ discard block |
||
| 726 | 785 | // Automatic line break |
| 727 | 786 | if($sep==-1) |
| 728 | 787 | { |
| 729 | - if($i==$j) |
|
| 730 | - $i++; |
|
| 788 | + if($i==$j) { |
|
| 789 | + $i++; |
|
| 790 | + } |
|
| 731 | 791 | if($this->ws>0) |
| 732 | 792 | { |
| 733 | 793 | $this->ws = 0; |
| 734 | 794 | $this->_out('0 Tw'); |
| 735 | 795 | } |
| 736 | 796 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 737 | - } |
|
| 738 | - else |
|
| 797 | + } else |
|
| 739 | 798 | { |
| 740 | 799 | if($align=='J') |
| 741 | 800 | { |
@@ -750,11 +809,12 @@ discard block |
||
| 750 | 809 | $l = 0; |
| 751 | 810 | $ns = 0; |
| 752 | 811 | $nl++; |
| 753 | - if($border && $nl==2) |
|
| 754 | - $b = $b2; |
|
| 812 | + if($border && $nl==2) { |
|
| 813 | + $b = $b2; |
|
| 814 | + } |
|
| 815 | + } else { |
|
| 816 | + $i++; |
|
| 755 | 817 | } |
| 756 | - else |
|
| 757 | - $i++; |
|
| 758 | 818 | } |
| 759 | 819 | // Last chunk |
| 760 | 820 | if($this->ws>0) |
@@ -762,8 +822,9 @@ discard block |
||
| 762 | 822 | $this->ws = 0; |
| 763 | 823 | $this->_out('0 Tw'); |
| 764 | 824 | } |
| 765 | - if($border && strpos($border,'B')!==false) |
|
| 766 | - $b .= 'B'; |
|
| 825 | + if($border && strpos($border,'B')!==false) { |
|
| 826 | + $b .= 'B'; |
|
| 827 | + } |
|
| 767 | 828 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 768 | 829 | $this->x = $this->lMargin; |
| 769 | 830 | } |
@@ -771,8 +832,9 @@ discard block |
||
| 771 | 832 | function Write($h, $txt, $link='') |
| 772 | 833 | { |
| 773 | 834 | // Output text in flowing mode |
| 774 | - if(!isset($this->CurrentFont)) |
|
| 775 | - $this->Error('No font has been set'); |
|
| 835 | + if(!isset($this->CurrentFont)) { |
|
| 836 | + $this->Error('No font has been set'); |
|
| 837 | + } |
|
| 776 | 838 | $cw = &$this->CurrentFont['cw']; |
| 777 | 839 | $w = $this->w-$this->rMargin-$this->x; |
| 778 | 840 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
@@ -804,8 +866,9 @@ discard block |
||
| 804 | 866 | $nl++; |
| 805 | 867 | continue; |
| 806 | 868 | } |
| 807 | - if($c==' ') |
|
| 808 | - $sep = $i; |
|
| 869 | + if($c==' ') { |
|
| 870 | + $sep = $i; |
|
| 871 | + } |
|
| 809 | 872 | $l += $cw[$c]; |
| 810 | 873 | if($l>$wmax) |
| 811 | 874 | { |
@@ -823,11 +886,11 @@ discard block |
||
| 823 | 886 | $nl++; |
| 824 | 887 | continue; |
| 825 | 888 | } |
| 826 | - if($i==$j) |
|
| 827 | - $i++; |
|
| 889 | + if($i==$j) { |
|
| 890 | + $i++; |
|
| 891 | + } |
|
| 828 | 892 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
| 829 | - } |
|
| 830 | - else |
|
| 893 | + } else |
|
| 831 | 894 | { |
| 832 | 895 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); |
| 833 | 896 | $i = $sep+1; |
@@ -842,52 +905,58 @@ discard block |
||
| 842 | 905 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
| 843 | 906 | } |
| 844 | 907 | $nl++; |
| 908 | + } else { |
|
| 909 | + $i++; |
|
| 845 | 910 | } |
| 846 | - else |
|
| 847 | - $i++; |
|
| 848 | 911 | } |
| 849 | 912 | // Last chunk |
| 850 | - if($i!=$j) |
|
| 851 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
| 852 | -} |
|
| 913 | + if($i!=$j) { |
|
| 914 | + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
| 915 | + } |
|
| 916 | + } |
|
| 853 | 917 | |
| 854 | 918 | function Ln($h=null) |
| 855 | 919 | { |
| 856 | 920 | // Line feed; default value is the last cell height |
| 857 | 921 | $this->x = $this->lMargin; |
| 858 | - if($h===null) |
|
| 859 | - $this->y += $this->lasth; |
|
| 860 | - else |
|
| 861 | - $this->y += $h; |
|
| 862 | -} |
|
| 922 | + if($h===null) { |
|
| 923 | + $this->y += $this->lasth; |
|
| 924 | + } else { |
|
| 925 | + $this->y += $h; |
|
| 926 | + } |
|
| 927 | + } |
|
| 863 | 928 | |
| 864 | 929 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
| 865 | 930 | { |
| 866 | 931 | // Put an image on the page |
| 867 | - if($file=='') |
|
| 868 | - $this->Error('Image file name is empty'); |
|
| 932 | + if($file=='') { |
|
| 933 | + $this->Error('Image file name is empty'); |
|
| 934 | + } |
|
| 869 | 935 | if(!isset($this->images[$file])) |
| 870 | 936 | { |
| 871 | 937 | // First use of this image, get info |
| 872 | 938 | if($type=='') |
| 873 | 939 | { |
| 874 | 940 | $pos = strrpos($file,'.'); |
| 875 | - if(!$pos) |
|
| 876 | - $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 941 | + if(!$pos) { |
|
| 942 | + $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 943 | + } |
|
| 877 | 944 | $type = substr($file,$pos+1); |
| 878 | 945 | } |
| 879 | 946 | $type = strtolower($type); |
| 880 | - if($type=='jpeg') |
|
| 881 | - $type = 'jpg'; |
|
| 947 | + if($type=='jpeg') { |
|
| 948 | + $type = 'jpg'; |
|
| 949 | + } |
|
| 882 | 950 | $mtd = '_parse'.$type; |
| 883 | - if(!method_exists($this,$mtd)) |
|
| 884 | - $this->Error('Unsupported image type: '.$type); |
|
| 951 | + if(!method_exists($this,$mtd)) { |
|
| 952 | + $this->Error('Unsupported image type: '.$type); |
|
| 953 | + } |
|
| 885 | 954 | $info = $this->$mtd($file); |
| 886 | 955 | $info['i'] = count($this->images)+1; |
| 887 | 956 | $this->images[$file] = $info; |
| 957 | + } else { |
|
| 958 | + $info = $this->images[$file]; |
|
| 888 | 959 | } |
| 889 | - else |
|
| 890 | - $info = $this->images[$file]; |
|
| 891 | 960 | |
| 892 | 961 | // Automatic width and height calculation if needed |
| 893 | 962 | if($w==0 && $h==0) |
@@ -896,14 +965,18 @@ discard block |
||
| 896 | 965 | $w = -96; |
| 897 | 966 | $h = -96; |
| 898 | 967 | } |
| 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']; |
|
| 968 | + if($w<0) { |
|
| 969 | + $w = -$info['w']*72/$w/$this->k; |
|
| 970 | + } |
|
| 971 | + if($h<0) { |
|
| 972 | + $h = -$info['h']*72/$h/$this->k; |
|
| 973 | + } |
|
| 974 | + if($w==0) { |
|
| 975 | + $w = $h*$info['w']/$info['h']; |
|
| 976 | + } |
|
| 977 | + if($h==0) { |
|
| 978 | + $h = $w*$info['h']/$info['w']; |
|
| 979 | + } |
|
| 907 | 980 | |
| 908 | 981 | // Flowing mode |
| 909 | 982 | if($y===null) |
@@ -919,12 +992,14 @@ discard block |
||
| 919 | 992 | $this->y += $h; |
| 920 | 993 | } |
| 921 | 994 | |
| 922 | - if($x===null) |
|
| 923 | - $x = $this->x; |
|
| 995 | + if($x===null) { |
|
| 996 | + $x = $this->x; |
|
| 997 | + } |
|
| 924 | 998 | $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 | -} |
|
| 999 | + if($link) { |
|
| 1000 | + $this->Link($x,$y,$w,$h,$link); |
|
| 1001 | + } |
|
| 1002 | + } |
|
| 928 | 1003 | |
| 929 | 1004 | function GetPageWidth() |
| 930 | 1005 | { |
@@ -947,11 +1022,12 @@ discard block |
||
| 947 | 1022 | function SetX($x) |
| 948 | 1023 | { |
| 949 | 1024 | // Set x position |
| 950 | - if($x>=0) |
|
| 951 | - $this->x = $x; |
|
| 952 | - else |
|
| 953 | - $this->x = $this->w+$x; |
|
| 954 | -} |
|
| 1025 | + if($x>=0) { |
|
| 1026 | + $this->x = $x; |
|
| 1027 | + } else { |
|
| 1028 | + $this->x = $this->w+$x; |
|
| 1029 | + } |
|
| 1030 | + } |
|
| 955 | 1031 | |
| 956 | 1032 | function GetY() |
| 957 | 1033 | { |
@@ -962,13 +1038,15 @@ discard block |
||
| 962 | 1038 | function SetY($y, $resetX=true) |
| 963 | 1039 | { |
| 964 | 1040 | // 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 | -} |
|
| 1041 | + if($y>=0) { |
|
| 1042 | + $this->y = $y; |
|
| 1043 | + } else { |
|
| 1044 | + $this->y = $this->h+$y; |
|
| 1045 | + } |
|
| 1046 | + if($resetX) { |
|
| 1047 | + $this->x = $this->lMargin; |
|
| 1048 | + } |
|
| 1049 | + } |
|
| 972 | 1050 | |
| 973 | 1051 | function SetXY($x, $y) |
| 974 | 1052 | { |
@@ -988,10 +1066,12 @@ discard block |
||
| 988 | 1066 | $dest = $name; |
| 989 | 1067 | $name = $tmp; |
| 990 | 1068 | } |
| 991 | - if($dest=='') |
|
| 992 | - $dest = 'I'; |
|
| 993 | - if($name=='') |
|
| 994 | - $name = 'doc.pdf'; |
|
| 1069 | + if($dest=='') { |
|
| 1070 | + $dest = 'I'; |
|
| 1071 | + } |
|
| 1072 | + if($name=='') { |
|
| 1073 | + $name = 'doc.pdf'; |
|
| 1074 | + } |
|
| 995 | 1075 | switch(strtoupper($dest)) |
| 996 | 1076 | { |
| 997 | 1077 | case 'I': |
@@ -1018,8 +1098,9 @@ discard block |
||
| 1018 | 1098 | break; |
| 1019 | 1099 | case 'F': |
| 1020 | 1100 | // Save to local file |
| 1021 | - if(!file_put_contents($name,$this->buffer)) |
|
| 1022 | - $this->Error('Unable to create output file: '.$name); |
|
| 1101 | + if(!file_put_contents($name,$this->buffer)) { |
|
| 1102 | + $this->Error('Unable to create output file: '.$name); |
|
| 1103 | + } |
|
| 1023 | 1104 | break; |
| 1024 | 1105 | case 'S': |
| 1025 | 1106 | // Return as a string |
@@ -1037,16 +1118,18 @@ discard block |
||
| 1037 | 1118 | protected function _dochecks() |
| 1038 | 1119 | { |
| 1039 | 1120 | // Check mbstring overloading |
| 1040 | - if(ini_get('mbstring.func_overload') & 2) |
|
| 1041 | - $this->Error('mbstring overloading must be disabled'); |
|
| 1042 | -} |
|
| 1121 | + if(ini_get('mbstring.func_overload') & 2) { |
|
| 1122 | + $this->Error('mbstring overloading must be disabled'); |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1043 | 1125 | |
| 1044 | 1126 | protected function _checkoutput() |
| 1045 | 1127 | { |
| 1046 | 1128 | if(PHP_SAPI!='cli') |
| 1047 | 1129 | { |
| 1048 | - if(headers_sent($file,$line)) |
|
| 1049 | - $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
| 1130 | + if(headers_sent($file,$line)) { |
|
| 1131 | + $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
| 1132 | + } |
|
| 1050 | 1133 | } |
| 1051 | 1134 | if(ob_get_length()) |
| 1052 | 1135 | { |
@@ -1055,9 +1138,9 @@ discard block |
||
| 1055 | 1138 | { |
| 1056 | 1139 | // It contains only a UTF-8 BOM and/or whitespace, let's clean it |
| 1057 | 1140 | ob_clean(); |
| 1141 | + } else { |
|
| 1142 | + $this->Error("Some data has already been output, can't send PDF file"); |
|
| 1058 | 1143 | } |
| 1059 | - else |
|
| 1060 | - $this->Error("Some data has already been output, can't send PDF file"); |
|
| 1061 | 1144 | } |
| 1062 | 1145 | } |
| 1063 | 1146 | |
@@ -1066,17 +1149,18 @@ discard block |
||
| 1066 | 1149 | if(is_string($size)) |
| 1067 | 1150 | { |
| 1068 | 1151 | $size = strtolower($size); |
| 1069 | - if(!isset($this->StdPageSizes[$size])) |
|
| 1070 | - $this->Error('Unknown page size: '.$size); |
|
| 1152 | + if(!isset($this->StdPageSizes[$size])) { |
|
| 1153 | + $this->Error('Unknown page size: '.$size); |
|
| 1154 | + } |
|
| 1071 | 1155 | $a = $this->StdPageSizes[$size]; |
| 1072 | 1156 | return array($a[0]/$this->k, $a[1]/$this->k); |
| 1073 | - } |
|
| 1074 | - else |
|
| 1157 | + } else |
|
| 1075 | 1158 | { |
| 1076 | - if($size[0]>$size[1]) |
|
| 1077 | - return array($size[1], $size[0]); |
|
| 1078 | - else |
|
| 1079 | - return $size; |
|
| 1159 | + if($size[0]>$size[1]) { |
|
| 1160 | + return array($size[1], $size[0]); |
|
| 1161 | + } else { |
|
| 1162 | + return $size; |
|
| 1163 | + } |
|
| 1080 | 1164 | } |
| 1081 | 1165 | } |
| 1082 | 1166 | |
@@ -1090,14 +1174,16 @@ discard block |
||
| 1090 | 1174 | $this->y = $this->tMargin; |
| 1091 | 1175 | $this->FontFamily = ''; |
| 1092 | 1176 | // Check page size and orientation |
| 1093 | - if($orientation=='') |
|
| 1094 | - $orientation = $this->DefOrientation; |
|
| 1095 | - else |
|
| 1096 | - $orientation = strtoupper($orientation[0]); |
|
| 1097 | - if($size=='') |
|
| 1098 | - $size = $this->DefPageSize; |
|
| 1099 | - else |
|
| 1100 | - $size = $this->_getpagesize($size); |
|
| 1177 | + if($orientation=='') { |
|
| 1178 | + $orientation = $this->DefOrientation; |
|
| 1179 | + } else { |
|
| 1180 | + $orientation = strtoupper($orientation[0]); |
|
| 1181 | + } |
|
| 1182 | + if($size=='') { |
|
| 1183 | + $size = $this->DefPageSize; |
|
| 1184 | + } else { |
|
| 1185 | + $size = $this->_getpagesize($size); |
|
| 1186 | + } |
|
| 1101 | 1187 | if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) |
| 1102 | 1188 | { |
| 1103 | 1189 | // New size or orientation |
@@ -1105,8 +1191,7 @@ discard block |
||
| 1105 | 1191 | { |
| 1106 | 1192 | $this->w = $size[0]; |
| 1107 | 1193 | $this->h = $size[1]; |
| 1108 | - } |
|
| 1109 | - else |
|
| 1194 | + } else |
|
| 1110 | 1195 | { |
| 1111 | 1196 | $this->w = $size[1]; |
| 1112 | 1197 | $this->h = $size[0]; |
@@ -1117,12 +1202,14 @@ discard block |
||
| 1117 | 1202 | $this->CurOrientation = $orientation; |
| 1118 | 1203 | $this->CurPageSize = $size; |
| 1119 | 1204 | } |
| 1120 | - if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) |
|
| 1121 | - $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1205 | + if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) { |
|
| 1206 | + $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1207 | + } |
|
| 1122 | 1208 | if($rotation!=0) |
| 1123 | 1209 | { |
| 1124 | - if($rotation%90!=0) |
|
| 1125 | - $this->Error('Incorrect rotation value: '.$rotation); |
|
| 1210 | + if($rotation%90!=0) { |
|
| 1211 | + $this->Error('Incorrect rotation value: '.$rotation); |
|
| 1212 | + } |
|
| 1126 | 1213 | $this->CurRotation = $rotation; |
| 1127 | 1214 | $this->PageInfo[$this->page]['rotation'] = $rotation; |
| 1128 | 1215 | } |
@@ -1136,15 +1223,19 @@ discard block |
||
| 1136 | 1223 | protected function _loadfont($font) |
| 1137 | 1224 | { |
| 1138 | 1225 | // Load a font definition file from the font directory |
| 1139 | - if(strpos($font,'/')!==false || strpos($font,"\\")!==false) |
|
| 1140 | - $this->Error('Incorrect font definition file name: '.$font); |
|
| 1226 | + if(strpos($font,'/')!==false || strpos($font,"\\")!==false) { |
|
| 1227 | + $this->Error('Incorrect font definition file name: '.$font); |
|
| 1228 | + } |
|
| 1141 | 1229 | include($this->fontpath.$font); |
| 1142 | - if(!isset($name)) |
|
| 1143 | - $this->Error('Could not include font definition file'); |
|
| 1144 | - if(isset($enc)) |
|
| 1145 | - $enc = strtolower($enc); |
|
| 1146 | - if(!isset($subsetted)) |
|
| 1147 | - $subsetted = false; |
|
| 1230 | + if(!isset($name)) { |
|
| 1231 | + $this->Error('Could not include font definition file'); |
|
| 1232 | + } |
|
| 1233 | + if(isset($enc)) { |
|
| 1234 | + $enc = strtolower($enc); |
|
| 1235 | + } |
|
| 1236 | + if(!isset($subsetted)) { |
|
| 1237 | + $subsetted = false; |
|
| 1238 | + } |
|
| 1148 | 1239 | return get_defined_vars(); |
| 1149 | 1240 | } |
| 1150 | 1241 | |
@@ -1154,8 +1245,9 @@ discard block |
||
| 1154 | 1245 | $nb = strlen($s); |
| 1155 | 1246 | for($i=0;$i<$nb;$i++) |
| 1156 | 1247 | { |
| 1157 | - if(ord($s[$i])>127) |
|
| 1158 | - return false; |
|
| 1248 | + if(ord($s[$i])>127) { |
|
| 1249 | + return false; |
|
| 1250 | + } |
|
| 1159 | 1251 | } |
| 1160 | 1252 | return true; |
| 1161 | 1253 | } |
@@ -1163,15 +1255,18 @@ discard block |
||
| 1163 | 1255 | protected function _httpencode($param, $value, $isUTF8) |
| 1164 | 1256 | { |
| 1165 | 1257 | // Encode HTTP header field parameter |
| 1166 | - if($this->_isascii($value)) |
|
| 1167 | - return $param.'="'.$value.'"'; |
|
| 1168 | - if(!$isUTF8) |
|
| 1169 | - $value = utf8_encode($value); |
|
| 1170 | - if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) |
|
| 1171 | - return $param.'="'.rawurlencode($value).'"'; |
|
| 1172 | - else |
|
| 1173 | - return $param."*=UTF-8''".rawurlencode($value); |
|
| 1174 | -} |
|
| 1258 | + if($this->_isascii($value)) { |
|
| 1259 | + return $param.'="'.$value.'"'; |
|
| 1260 | + } |
|
| 1261 | + if(!$isUTF8) { |
|
| 1262 | + $value = utf8_encode($value); |
|
| 1263 | + } |
|
| 1264 | + if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) { |
|
| 1265 | + return $param.'="'.rawurlencode($value).'"'; |
|
| 1266 | + } else { |
|
| 1267 | + return $param."*=UTF-8''".rawurlencode($value); |
|
| 1268 | + } |
|
| 1269 | + } |
|
| 1175 | 1270 | |
| 1176 | 1271 | protected function _UTF8toUTF16($s) |
| 1177 | 1272 | { |
@@ -1189,15 +1284,13 @@ discard block |
||
| 1189 | 1284 | $c3 = ord($s[$i++]); |
| 1190 | 1285 | $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
| 1191 | 1286 | $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
| 1192 | - } |
|
| 1193 | - elseif($c1>=192) |
|
| 1287 | + } elseif($c1>=192) |
|
| 1194 | 1288 | { |
| 1195 | 1289 | // 2-byte character |
| 1196 | 1290 | $c2 = ord($s[$i++]); |
| 1197 | 1291 | $res .= chr(($c1 & 0x1C)>>2); |
| 1198 | 1292 | $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
| 1199 | - } |
|
| 1200 | - else |
|
| 1293 | + } else |
|
| 1201 | 1294 | { |
| 1202 | 1295 | // Single-byte character |
| 1203 | 1296 | $res .= "\0".chr($c1); |
@@ -1209,17 +1302,19 @@ discard block |
||
| 1209 | 1302 | protected function _escape($s) |
| 1210 | 1303 | { |
| 1211 | 1304 | // Escape special characters |
| 1212 | - if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) |
|
| 1213 | - return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
| 1214 | - else |
|
| 1215 | - return $s; |
|
| 1216 | -} |
|
| 1305 | + if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) { |
|
| 1306 | + return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
| 1307 | + } else { |
|
| 1308 | + return $s; |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1217 | 1311 | |
| 1218 | 1312 | protected function _textstring($s) |
| 1219 | 1313 | { |
| 1220 | 1314 | // Format a text string |
| 1221 | - if(!$this->_isascii($s)) |
|
| 1222 | - $s = $this->_UTF8toUTF16($s); |
|
| 1315 | + if(!$this->_isascii($s)) { |
|
| 1316 | + $s = $this->_UTF8toUTF16($s); |
|
| 1317 | + } |
|
| 1223 | 1318 | return '('.$this->_escape($s).')'; |
| 1224 | 1319 | } |
| 1225 | 1320 | |
@@ -1236,16 +1331,19 @@ discard block |
||
| 1236 | 1331 | { |
| 1237 | 1332 | // Extract info from a JPEG file |
| 1238 | 1333 | $a = getimagesize($file); |
| 1239 | - if(!$a) |
|
| 1240 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1241 | - if($a[2]!=2) |
|
| 1242 | - $this->Error('Not a JPEG file: '.$file); |
|
| 1243 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1244 | - $colspace = 'DeviceRGB'; |
|
| 1245 | - elseif($a['channels']==4) |
|
| 1246 | - $colspace = 'DeviceCMYK'; |
|
| 1247 | - else |
|
| 1248 | - $colspace = 'DeviceGray'; |
|
| 1334 | + if(!$a) { |
|
| 1335 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1336 | + } |
|
| 1337 | + if($a[2]!=2) { |
|
| 1338 | + $this->Error('Not a JPEG file: '.$file); |
|
| 1339 | + } |
|
| 1340 | + if(!isset($a['channels']) || $a['channels']==3) { |
|
| 1341 | + $colspace = 'DeviceRGB'; |
|
| 1342 | + } elseif($a['channels']==4) { |
|
| 1343 | + $colspace = 'DeviceCMYK'; |
|
| 1344 | + } else { |
|
| 1345 | + $colspace = 'DeviceGray'; |
|
| 1346 | + } |
|
| 1249 | 1347 | $bpc = isset($a['bits']) ? $a['bits'] : 8; |
| 1250 | 1348 | $data = file_get_contents($file); |
| 1251 | 1349 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
@@ -1255,8 +1353,9 @@ discard block |
||
| 1255 | 1353 | { |
| 1256 | 1354 | // Extract info from a PNG file |
| 1257 | 1355 | $f = fopen($file,'rb'); |
| 1258 | - if(!$f) |
|
| 1259 | - $this->Error('Can\'t open image file: '.$file); |
|
| 1356 | + if(!$f) { |
|
| 1357 | + $this->Error('Can\'t open image file: '.$file); |
|
| 1358 | + } |
|
| 1260 | 1359 | $info = $this->_parsepngstream($f,$file); |
| 1261 | 1360 | fclose($f); |
| 1262 | 1361 | return $info; |
@@ -1265,33 +1364,40 @@ discard block |
||
| 1265 | 1364 | protected function _parsepngstream($f, $file) |
| 1266 | 1365 | { |
| 1267 | 1366 | // Check signature |
| 1268 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1269 | - $this->Error('Not a PNG file: '.$file); |
|
| 1367 | + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { |
|
| 1368 | + $this->Error('Not a PNG file: '.$file); |
|
| 1369 | + } |
|
| 1270 | 1370 | |
| 1271 | 1371 | // Read header chunk |
| 1272 | 1372 | $this->_readstream($f,4); |
| 1273 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1274 | - $this->Error('Incorrect PNG file: '.$file); |
|
| 1373 | + if($this->_readstream($f,4)!='IHDR') { |
|
| 1374 | + $this->Error('Incorrect PNG file: '.$file); |
|
| 1375 | + } |
|
| 1275 | 1376 | $w = $this->_readint($f); |
| 1276 | 1377 | $h = $this->_readint($f); |
| 1277 | 1378 | $bpc = ord($this->_readstream($f,1)); |
| 1278 | - if($bpc>8) |
|
| 1279 | - $this->Error('16-bit depth not supported: '.$file); |
|
| 1379 | + if($bpc>8) { |
|
| 1380 | + $this->Error('16-bit depth not supported: '.$file); |
|
| 1381 | + } |
|
| 1280 | 1382 | $ct = ord($this->_readstream($f,1)); |
| 1281 | - if($ct==0 || $ct==4) |
|
| 1282 | - $colspace = 'DeviceGray'; |
|
| 1283 | - elseif($ct==2 || $ct==6) |
|
| 1284 | - $colspace = 'DeviceRGB'; |
|
| 1285 | - elseif($ct==3) |
|
| 1286 | - $colspace = 'Indexed'; |
|
| 1287 | - else |
|
| 1288 | - $this->Error('Unknown color type: '.$file); |
|
| 1289 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1290 | - $this->Error('Unknown compression method: '.$file); |
|
| 1291 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1292 | - $this->Error('Unknown filter method: '.$file); |
|
| 1293 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1294 | - $this->Error('Interlacing not supported: '.$file); |
|
| 1383 | + if($ct==0 || $ct==4) { |
|
| 1384 | + $colspace = 'DeviceGray'; |
|
| 1385 | + } elseif($ct==2 || $ct==6) { |
|
| 1386 | + $colspace = 'DeviceRGB'; |
|
| 1387 | + } elseif($ct==3) { |
|
| 1388 | + $colspace = 'Indexed'; |
|
| 1389 | + } else { |
|
| 1390 | + $this->Error('Unknown color type: '.$file); |
|
| 1391 | + } |
|
| 1392 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1393 | + $this->Error('Unknown compression method: '.$file); |
|
| 1394 | + } |
|
| 1395 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1396 | + $this->Error('Unknown filter method: '.$file); |
|
| 1397 | + } |
|
| 1398 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1399 | + $this->Error('Interlacing not supported: '.$file); |
|
| 1400 | + } |
|
| 1295 | 1401 | $this->_readstream($f,4); |
| 1296 | 1402 | $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
| 1297 | 1403 | |
@@ -1308,44 +1414,45 @@ discard block |
||
| 1308 | 1414 | // Read palette |
| 1309 | 1415 | $pal = $this->_readstream($f,$n); |
| 1310 | 1416 | $this->_readstream($f,4); |
| 1311 | - } |
|
| 1312 | - elseif($type=='tRNS') |
|
| 1417 | + } elseif($type=='tRNS') |
|
| 1313 | 1418 | { |
| 1314 | 1419 | // Read transparency info |
| 1315 | 1420 | $t = $this->_readstream($f,$n); |
| 1316 | - if($ct==0) |
|
| 1317 | - $trns = array(ord(substr($t,1,1))); |
|
| 1318 | - elseif($ct==2) |
|
| 1319 | - $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1320 | - else |
|
| 1421 | + if($ct==0) { |
|
| 1422 | + $trns = array(ord(substr($t,1,1))); |
|
| 1423 | + } elseif($ct==2) { |
|
| 1424 | + $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1425 | + } else |
|
| 1321 | 1426 | { |
| 1322 | 1427 | $pos = strpos($t,chr(0)); |
| 1323 | - if($pos!==false) |
|
| 1324 | - $trns = array($pos); |
|
| 1428 | + if($pos!==false) { |
|
| 1429 | + $trns = array($pos); |
|
| 1430 | + } |
|
| 1325 | 1431 | } |
| 1326 | 1432 | $this->_readstream($f,4); |
| 1327 | - } |
|
| 1328 | - elseif($type=='IDAT') |
|
| 1433 | + } elseif($type=='IDAT') |
|
| 1329 | 1434 | { |
| 1330 | 1435 | // Read image data block |
| 1331 | 1436 | $data .= $this->_readstream($f,$n); |
| 1332 | 1437 | $this->_readstream($f,4); |
| 1438 | + } elseif($type=='IEND') { |
|
| 1439 | + break; |
|
| 1440 | + } else { |
|
| 1441 | + $this->_readstream($f,$n+4); |
|
| 1333 | 1442 | } |
| 1334 | - elseif($type=='IEND') |
|
| 1335 | - break; |
|
| 1336 | - else |
|
| 1337 | - $this->_readstream($f,$n+4); |
|
| 1338 | 1443 | } |
| 1339 | 1444 | while($n); |
| 1340 | 1445 | |
| 1341 | - if($colspace=='Indexed' && empty($pal)) |
|
| 1342 | - $this->Error('Missing palette in '.$file); |
|
| 1446 | + if($colspace=='Indexed' && empty($pal)) { |
|
| 1447 | + $this->Error('Missing palette in '.$file); |
|
| 1448 | + } |
|
| 1343 | 1449 | $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); |
| 1344 | 1450 | if($ct>=4) |
| 1345 | 1451 | { |
| 1346 | 1452 | // Extract alpha channel |
| 1347 | - if(!function_exists('gzuncompress')) |
|
| 1348 | - $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
| 1453 | + if(!function_exists('gzuncompress')) { |
|
| 1454 | + $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
| 1455 | + } |
|
| 1349 | 1456 | $data = gzuncompress($data); |
| 1350 | 1457 | $color = ''; |
| 1351 | 1458 | $alpha = ''; |
@@ -1362,8 +1469,7 @@ discard block |
||
| 1362 | 1469 | $color .= preg_replace('/(.)./s','$1',$line); |
| 1363 | 1470 | $alpha .= preg_replace('/.(.)/s','$1',$line); |
| 1364 | 1471 | } |
| 1365 | - } |
|
| 1366 | - else |
|
| 1472 | + } else |
|
| 1367 | 1473 | { |
| 1368 | 1474 | // RGB image |
| 1369 | 1475 | $len = 4*$w; |
@@ -1381,8 +1487,9 @@ discard block |
||
| 1381 | 1487 | $data = gzcompress($color); |
| 1382 | 1488 | $info['smask'] = gzcompress($alpha); |
| 1383 | 1489 | $this->WithAlpha = true; |
| 1384 | - if($this->PDFVersion<'1.4') |
|
| 1385 | - $this->PDFVersion = '1.4'; |
|
| 1490 | + if($this->PDFVersion<'1.4') { |
|
| 1491 | + $this->PDFVersion = '1.4'; |
|
| 1492 | + } |
|
| 1386 | 1493 | } |
| 1387 | 1494 | $info['data'] = $data; |
| 1388 | 1495 | return $info; |
@@ -1395,13 +1502,15 @@ discard block |
||
| 1395 | 1502 | while($n>0 && !feof($f)) |
| 1396 | 1503 | { |
| 1397 | 1504 | $s = fread($f,$n); |
| 1398 | - if($s===false) |
|
| 1399 | - $this->Error('Error while reading stream'); |
|
| 1505 | + if($s===false) { |
|
| 1506 | + $this->Error('Error while reading stream'); |
|
| 1507 | + } |
|
| 1400 | 1508 | $n -= strlen($s); |
| 1401 | 1509 | $res .= $s; |
| 1402 | 1510 | } |
| 1403 | - if($n>0) |
|
| 1404 | - $this->Error('Unexpected end of stream'); |
|
| 1511 | + if($n>0) { |
|
| 1512 | + $this->Error('Unexpected end of stream'); |
|
| 1513 | + } |
|
| 1405 | 1514 | return $res; |
| 1406 | 1515 | } |
| 1407 | 1516 | |
@@ -1415,21 +1524,25 @@ discard block |
||
| 1415 | 1524 | protected function _parsegif($file) |
| 1416 | 1525 | { |
| 1417 | 1526 | // Extract info from a GIF file (via PNG conversion) |
| 1418 | - if(!function_exists('imagepng')) |
|
| 1419 | - $this->Error('GD extension is required for GIF support'); |
|
| 1420 | - if(!function_exists('imagecreatefromgif')) |
|
| 1421 | - $this->Error('GD has no GIF read support'); |
|
| 1527 | + if(!function_exists('imagepng')) { |
|
| 1528 | + $this->Error('GD extension is required for GIF support'); |
|
| 1529 | + } |
|
| 1530 | + if(!function_exists('imagecreatefromgif')) { |
|
| 1531 | + $this->Error('GD has no GIF read support'); |
|
| 1532 | + } |
|
| 1422 | 1533 | $im = imagecreatefromgif($file); |
| 1423 | - if(!$im) |
|
| 1424 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1534 | + if(!$im) { |
|
| 1535 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1536 | + } |
|
| 1425 | 1537 | imageinterlace($im,0); |
| 1426 | 1538 | ob_start(); |
| 1427 | 1539 | imagepng($im); |
| 1428 | 1540 | $data = ob_get_clean(); |
| 1429 | 1541 | imagedestroy($im); |
| 1430 | 1542 | $f = fopen('php://temp','rb+'); |
| 1431 | - if(!$f) |
|
| 1432 | - $this->Error('Unable to create memory stream'); |
|
| 1543 | + if(!$f) { |
|
| 1544 | + $this->Error('Unable to create memory stream'); |
|
| 1545 | + } |
|
| 1433 | 1546 | fwrite($f,$data); |
| 1434 | 1547 | rewind($f); |
| 1435 | 1548 | $info = $this->_parsepngstream($f,$file); |
@@ -1440,15 +1553,16 @@ discard block |
||
| 1440 | 1553 | protected function _out($s) |
| 1441 | 1554 | { |
| 1442 | 1555 | // Add a line to the document |
| 1443 | - if($this->state==2) |
|
| 1444 | - $this->pages[$this->page] .= $s."\n"; |
|
| 1445 | - elseif($this->state==1) |
|
| 1446 | - $this->_put($s); |
|
| 1447 | - elseif($this->state==0) |
|
| 1448 | - $this->Error('No page has been added yet'); |
|
| 1449 | - elseif($this->state==3) |
|
| 1450 | - $this->Error('The document is closed'); |
|
| 1451 | -} |
|
| 1556 | + if($this->state==2) { |
|
| 1557 | + $this->pages[$this->page] .= $s."\n"; |
|
| 1558 | + } elseif($this->state==1) { |
|
| 1559 | + $this->_put($s); |
|
| 1560 | + } elseif($this->state==0) { |
|
| 1561 | + $this->Error('No page has been added yet'); |
|
| 1562 | + } elseif($this->state==3) { |
|
| 1563 | + $this->Error('The document is closed'); |
|
| 1564 | + } |
|
| 1565 | + } |
|
| 1452 | 1566 | |
| 1453 | 1567 | protected function _put($s) |
| 1454 | 1568 | { |
@@ -1463,8 +1577,9 @@ discard block |
||
| 1463 | 1577 | protected function _newobj($n=null) |
| 1464 | 1578 | { |
| 1465 | 1579 | // Begin a new object |
| 1466 | - if($n===null) |
|
| 1467 | - $n = ++$this->n; |
|
| 1580 | + if($n===null) { |
|
| 1581 | + $n = ++$this->n; |
|
| 1582 | + } |
|
| 1468 | 1583 | $this->offsets[$n] = $this->_getoffset(); |
| 1469 | 1584 | $this->_put($n.' 0 obj'); |
| 1470 | 1585 | } |
@@ -1482,9 +1597,9 @@ discard block |
||
| 1482 | 1597 | { |
| 1483 | 1598 | $entries = '/Filter /FlateDecode '; |
| 1484 | 1599 | $data = gzcompress($data); |
| 1600 | + } else { |
|
| 1601 | + $entries = ''; |
|
| 1485 | 1602 | } |
| 1486 | - else |
|
| 1487 | - $entries = ''; |
|
| 1488 | 1603 | $entries .= '/Length '.strlen($data); |
| 1489 | 1604 | $this->_newobj(); |
| 1490 | 1605 | $this->_put('<<'.$entries.'>>'); |
@@ -1497,41 +1612,47 @@ discard block |
||
| 1497 | 1612 | $this->_newobj(); |
| 1498 | 1613 | $this->_put('<</Type /Page'); |
| 1499 | 1614 | $this->_put('/Parent 1 0 R'); |
| 1500 | - if(isset($this->PageInfo[$n]['size'])) |
|
| 1501 | - $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); |
|
| 1502 | - if(isset($this->PageInfo[$n]['rotation'])) |
|
| 1503 | - $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); |
|
| 1615 | + if(isset($this->PageInfo[$n]['size'])) { |
|
| 1616 | + $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); |
|
| 1617 | + } |
|
| 1618 | + if(isset($this->PageInfo[$n]['rotation'])) { |
|
| 1619 | + $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); |
|
| 1620 | + } |
|
| 1504 | 1621 | $this->_put('/Resources 2 0 R'); |
| 1505 | 1622 | if(!empty($this->PageLinks[$n])) |
| 1506 | 1623 | { |
| 1507 | 1624 | $s = '/Annots ['; |
| 1508 | - foreach($this->PageLinks[$n] as $pl) |
|
| 1509 | - $s .= $pl[5].' 0 R '; |
|
| 1625 | + foreach($this->PageLinks[$n] as $pl) { |
|
| 1626 | + $s .= $pl[5].' 0 R '; |
|
| 1627 | + } |
|
| 1510 | 1628 | $s .= ']'; |
| 1511 | 1629 | $this->_put($s); |
| 1512 | 1630 | } |
| 1513 | - if($this->WithAlpha) |
|
| 1514 | - $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
| 1631 | + if($this->WithAlpha) { |
|
| 1632 | + $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
| 1633 | + } |
|
| 1515 | 1634 | $this->_put('/Contents '.($this->n+1).' 0 R>>'); |
| 1516 | 1635 | $this->_put('endobj'); |
| 1517 | 1636 | // Page content |
| 1518 | - if(!empty($this->AliasNbPages)) |
|
| 1519 | - $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); |
|
| 1637 | + if(!empty($this->AliasNbPages)) { |
|
| 1638 | + $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); |
|
| 1639 | + } |
|
| 1520 | 1640 | $this->_putstreamobject($this->pages[$n]); |
| 1521 | 1641 | // Annotations |
| 1522 | 1642 | foreach($this->PageLinks[$n] as $pl) |
| 1523 | 1643 | { |
| 1524 | 1644 | $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
| 1525 | 1645 | $s = '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
| 1526 | - if(is_string($pl[4])) |
|
| 1527 | - $s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1528 | - else |
|
| 1646 | + if(is_string($pl[4])) { |
|
| 1647 | + $s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1648 | + } else |
|
| 1529 | 1649 | { |
| 1530 | 1650 | $l = $this->links[$pl[4]]; |
| 1531 | - if(isset($this->PageInfo[$l[0]]['size'])) |
|
| 1532 | - $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 1533 | - else |
|
| 1534 | - $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 1651 | + if(isset($this->PageInfo[$l[0]]['size'])) { |
|
| 1652 | + $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 1653 | + } else { |
|
| 1654 | + $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 1655 | + } |
|
| 1535 | 1656 | $s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); |
| 1536 | 1657 | } |
| 1537 | 1658 | $this->_newobj(); |
@@ -1548,18 +1669,21 @@ discard block |
||
| 1548 | 1669 | { |
| 1549 | 1670 | $this->PageInfo[$i]['n'] = ++$n; |
| 1550 | 1671 | $n++; |
| 1551 | - foreach($this->PageLinks[$i] as &$pl) |
|
| 1552 | - $pl[5] = ++$n; |
|
| 1672 | + foreach($this->PageLinks[$i] as &$pl) { |
|
| 1673 | + $pl[5] = ++$n; |
|
| 1674 | + } |
|
| 1553 | 1675 | unset($pl); |
| 1554 | 1676 | } |
| 1555 | - for($i=1;$i<=$nb;$i++) |
|
| 1556 | - $this->_putpage($i); |
|
| 1677 | + for($i=1;$i<=$nb;$i++) { |
|
| 1678 | + $this->_putpage($i); |
|
| 1679 | + } |
|
| 1557 | 1680 | // Pages root |
| 1558 | 1681 | $this->_newobj(1); |
| 1559 | 1682 | $this->_put('<</Type /Pages'); |
| 1560 | 1683 | $kids = '/Kids ['; |
| 1561 | - for($i=1;$i<=$nb;$i++) |
|
| 1562 | - $kids .= $this->PageInfo[$i]['n'].' 0 R '; |
|
| 1684 | + for($i=1;$i<=$nb;$i++) { |
|
| 1685 | + $kids .= $this->PageInfo[$i]['n'].' 0 R '; |
|
| 1686 | + } |
|
| 1563 | 1687 | $kids .= ']'; |
| 1564 | 1688 | $this->_put($kids); |
| 1565 | 1689 | $this->_put('/Count '.$nb); |
@@ -1567,8 +1691,7 @@ discard block |
||
| 1567 | 1691 | { |
| 1568 | 1692 | $w = $this->DefPageSize[0]; |
| 1569 | 1693 | $h = $this->DefPageSize[1]; |
| 1570 | - } |
|
| 1571 | - else |
|
| 1694 | + } else |
|
| 1572 | 1695 | { |
| 1573 | 1696 | $w = $this->DefPageSize[1]; |
| 1574 | 1697 | $h = $this->DefPageSize[0]; |
@@ -1586,17 +1709,21 @@ discard block |
||
| 1586 | 1709 | $this->_newobj(); |
| 1587 | 1710 | $this->FontFiles[$file]['n'] = $this->n; |
| 1588 | 1711 | $font = file_get_contents($this->fontpath.$file,true); |
| 1589 | - if(!$font) |
|
| 1590 | - $this->Error('Font file not found: '.$file); |
|
| 1712 | + if(!$font) { |
|
| 1713 | + $this->Error('Font file not found: '.$file); |
|
| 1714 | + } |
|
| 1591 | 1715 | $compressed = (substr($file,-2)=='.z'); |
| 1592 | - if(!$compressed && isset($info['length2'])) |
|
| 1593 | - $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); |
|
| 1716 | + if(!$compressed && isset($info['length2'])) { |
|
| 1717 | + $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); |
|
| 1718 | + } |
|
| 1594 | 1719 | $this->_put('<</Length '.strlen($font)); |
| 1595 | - if($compressed) |
|
| 1596 | - $this->_put('/Filter /FlateDecode'); |
|
| 1720 | + if($compressed) { |
|
| 1721 | + $this->_put('/Filter /FlateDecode'); |
|
| 1722 | + } |
|
| 1597 | 1723 | $this->_put('/Length1 '.$info['length1']); |
| 1598 | - if(isset($info['length2'])) |
|
| 1599 | - $this->_put('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1724 | + if(isset($info['length2'])) { |
|
| 1725 | + $this->_put('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1726 | + } |
|
| 1600 | 1727 | $this->_put('>>'); |
| 1601 | 1728 | $this->_putstream($font); |
| 1602 | 1729 | $this->_put('endobj'); |
@@ -1617,10 +1744,11 @@ discard block |
||
| 1617 | 1744 | // ToUnicode CMap |
| 1618 | 1745 | if(isset($font['uv'])) |
| 1619 | 1746 | { |
| 1620 | - if(isset($font['enc'])) |
|
| 1621 | - $cmapkey = $font['enc']; |
|
| 1622 | - else |
|
| 1623 | - $cmapkey = $font['name']; |
|
| 1747 | + if(isset($font['enc'])) { |
|
| 1748 | + $cmapkey = $font['enc']; |
|
| 1749 | + } else { |
|
| 1750 | + $cmapkey = $font['name']; |
|
| 1751 | + } |
|
| 1624 | 1752 | if(!isset($this->cmaps[$cmapkey])) |
| 1625 | 1753 | { |
| 1626 | 1754 | $cmap = $this->_tounicodecmap($font['uv']); |
@@ -1632,8 +1760,9 @@ discard block |
||
| 1632 | 1760 | $this->fonts[$k]['n'] = $this->n+1; |
| 1633 | 1761 | $type = $font['type']; |
| 1634 | 1762 | $name = $font['name']; |
| 1635 | - if($font['subsetted']) |
|
| 1636 | - $name = 'AAAAAA+'.$name; |
|
| 1763 | + if($font['subsetted']) { |
|
| 1764 | + $name = 'AAAAAA+'.$name; |
|
| 1765 | + } |
|
| 1637 | 1766 | if($type=='Core') |
| 1638 | 1767 | { |
| 1639 | 1768 | // Core font |
@@ -1641,14 +1770,15 @@ discard block |
||
| 1641 | 1770 | $this->_put('<</Type /Font'); |
| 1642 | 1771 | $this->_put('/BaseFont /'.$name); |
| 1643 | 1772 | $this->_put('/Subtype /Type1'); |
| 1644 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1645 | - $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1646 | - if(isset($font['uv'])) |
|
| 1647 | - $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1773 | + if($name!='Symbol' && $name!='ZapfDingbats') { |
|
| 1774 | + $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1775 | + } |
|
| 1776 | + if(isset($font['uv'])) { |
|
| 1777 | + $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1778 | + } |
|
| 1648 | 1779 | $this->_put('>>'); |
| 1649 | 1780 | $this->_put('endobj'); |
| 1650 | - } |
|
| 1651 | - elseif($type=='Type1' || $type=='TrueType') |
|
| 1781 | + } elseif($type=='Type1' || $type=='TrueType') |
|
| 1652 | 1782 | { |
| 1653 | 1783 | // Additional Type1 or TrueType/OpenType font |
| 1654 | 1784 | $this->_newobj(); |
@@ -1658,38 +1788,43 @@ discard block |
||
| 1658 | 1788 | $this->_put('/FirstChar 32 /LastChar 255'); |
| 1659 | 1789 | $this->_put('/Widths '.($this->n+1).' 0 R'); |
| 1660 | 1790 | $this->_put('/FontDescriptor '.($this->n+2).' 0 R'); |
| 1661 | - if(isset($font['diff'])) |
|
| 1662 | - $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); |
|
| 1663 | - else |
|
| 1664 | - $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1665 | - if(isset($font['uv'])) |
|
| 1666 | - $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1791 | + if(isset($font['diff'])) { |
|
| 1792 | + $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); |
|
| 1793 | + } else { |
|
| 1794 | + $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1795 | + } |
|
| 1796 | + if(isset($font['uv'])) { |
|
| 1797 | + $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1798 | + } |
|
| 1667 | 1799 | $this->_put('>>'); |
| 1668 | 1800 | $this->_put('endobj'); |
| 1669 | 1801 | // Widths |
| 1670 | 1802 | $this->_newobj(); |
| 1671 | 1803 | $cw = &$font['cw']; |
| 1672 | 1804 | $s = '['; |
| 1673 | - for($i=32;$i<=255;$i++) |
|
| 1674 | - $s .= $cw[chr($i)].' '; |
|
| 1805 | + for($i=32;$i<=255;$i++) { |
|
| 1806 | + $s .= $cw[chr($i)].' '; |
|
| 1807 | + } |
|
| 1675 | 1808 | $this->_put($s.']'); |
| 1676 | 1809 | $this->_put('endobj'); |
| 1677 | 1810 | // Descriptor |
| 1678 | 1811 | $this->_newobj(); |
| 1679 | 1812 | $s = '<</Type /FontDescriptor /FontName /'.$name; |
| 1680 | - foreach($font['desc'] as $k=>$v) |
|
| 1681 | - $s .= ' /'.$k.' '.$v; |
|
| 1682 | - if(!empty($font['file'])) |
|
| 1683 | - $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1813 | + foreach($font['desc'] as $k=>$v) { |
|
| 1814 | + $s .= ' /'.$k.' '.$v; |
|
| 1815 | + } |
|
| 1816 | + if(!empty($font['file'])) { |
|
| 1817 | + $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1818 | + } |
|
| 1684 | 1819 | $this->_put($s.'>>'); |
| 1685 | 1820 | $this->_put('endobj'); |
| 1686 | - } |
|
| 1687 | - else |
|
| 1821 | + } else |
|
| 1688 | 1822 | { |
| 1689 | 1823 | // Allow for additional types |
| 1690 | 1824 | $mtd = '_put'.strtolower($type); |
| 1691 | - if(!method_exists($this,$mtd)) |
|
| 1692 | - $this->Error('Unsupported font type: '.$type); |
|
| 1825 | + if(!method_exists($this,$mtd)) { |
|
| 1826 | + $this->Error('Unsupported font type: '.$type); |
|
| 1827 | + } |
|
| 1693 | 1828 | $this->$mtd($font); |
| 1694 | 1829 | } |
| 1695 | 1830 | } |
@@ -1707,8 +1842,7 @@ discard block |
||
| 1707 | 1842 | { |
| 1708 | 1843 | $ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]); |
| 1709 | 1844 | $nbr++; |
| 1710 | - } |
|
| 1711 | - else |
|
| 1845 | + } else |
|
| 1712 | 1846 | { |
| 1713 | 1847 | $chars .= sprintf("<%02X> <%04X>\n",$c,$v); |
| 1714 | 1848 | $nbc++; |
@@ -1764,28 +1898,33 @@ discard block |
||
| 1764 | 1898 | $this->_put('/Subtype /Image'); |
| 1765 | 1899 | $this->_put('/Width '.$info['w']); |
| 1766 | 1900 | $this->_put('/Height '.$info['h']); |
| 1767 | - if($info['cs']=='Indexed') |
|
| 1768 | - $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1769 | - else |
|
| 1901 | + if($info['cs']=='Indexed') { |
|
| 1902 | + $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1903 | + } else |
|
| 1770 | 1904 | { |
| 1771 | 1905 | $this->_put('/ColorSpace /'.$info['cs']); |
| 1772 | - if($info['cs']=='DeviceCMYK') |
|
| 1773 | - $this->_put('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1906 | + if($info['cs']=='DeviceCMYK') { |
|
| 1907 | + $this->_put('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1908 | + } |
|
| 1774 | 1909 | } |
| 1775 | 1910 | $this->_put('/BitsPerComponent '.$info['bpc']); |
| 1776 | - if(isset($info['f'])) |
|
| 1777 | - $this->_put('/Filter /'.$info['f']); |
|
| 1778 | - if(isset($info['dp'])) |
|
| 1779 | - $this->_put('/DecodeParms <<'.$info['dp'].'>>'); |
|
| 1911 | + if(isset($info['f'])) { |
|
| 1912 | + $this->_put('/Filter /'.$info['f']); |
|
| 1913 | + } |
|
| 1914 | + if(isset($info['dp'])) { |
|
| 1915 | + $this->_put('/DecodeParms <<'.$info['dp'].'>>'); |
|
| 1916 | + } |
|
| 1780 | 1917 | if(isset($info['trns']) && is_array($info['trns'])) |
| 1781 | 1918 | { |
| 1782 | 1919 | $trns = ''; |
| 1783 | - for($i=0;$i<count($info['trns']);$i++) |
|
| 1784 | - $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1920 | + for($i=0;$i<count($info['trns']);$i++) { |
|
| 1921 | + $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1922 | + } |
|
| 1785 | 1923 | $this->_put('/Mask ['.$trns.']'); |
| 1786 | 1924 | } |
| 1787 | - if(isset($info['smask'])) |
|
| 1788 | - $this->_put('/SMask '.($this->n+1).' 0 R'); |
|
| 1925 | + if(isset($info['smask'])) { |
|
| 1926 | + $this->_put('/SMask '.($this->n+1).' 0 R'); |
|
| 1927 | + } |
|
| 1789 | 1928 | $this->_put('/Length '.strlen($info['data']).'>>'); |
| 1790 | 1929 | $this->_putstream($info['data']); |
| 1791 | 1930 | $this->_put('endobj'); |
@@ -1797,22 +1936,25 @@ discard block |
||
| 1797 | 1936 | $this->_putimage($smask); |
| 1798 | 1937 | } |
| 1799 | 1938 | // Palette |
| 1800 | - if($info['cs']=='Indexed') |
|
| 1801 | - $this->_putstreamobject($info['pal']); |
|
| 1802 | -} |
|
| 1939 | + if($info['cs']=='Indexed') { |
|
| 1940 | + $this->_putstreamobject($info['pal']); |
|
| 1941 | + } |
|
| 1942 | + } |
|
| 1803 | 1943 | |
| 1804 | 1944 | protected function _putxobjectdict() |
| 1805 | 1945 | { |
| 1806 | - foreach($this->images as $image) |
|
| 1807 | - $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1808 | -} |
|
| 1946 | + foreach($this->images as $image) { |
|
| 1947 | + $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1948 | + } |
|
| 1949 | + } |
|
| 1809 | 1950 | |
| 1810 | 1951 | protected function _putresourcedict() |
| 1811 | 1952 | { |
| 1812 | 1953 | $this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 1813 | 1954 | $this->_put('/Font <<'); |
| 1814 | - foreach($this->fonts as $font) |
|
| 1815 | - $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1955 | + foreach($this->fonts as $font) { |
|
| 1956 | + $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1957 | + } |
|
| 1816 | 1958 | $this->_put('>>'); |
| 1817 | 1959 | $this->_put('/XObject <<'); |
| 1818 | 1960 | $this->_putxobjectdict(); |
@@ -1835,30 +1977,33 @@ discard block |
||
| 1835 | 1977 | { |
| 1836 | 1978 | $this->metadata['Producer'] = 'FPDF '.FPDF_VERSION; |
| 1837 | 1979 | $this->metadata['CreationDate'] = 'D:'.@date('YmdHis'); |
| 1838 | - foreach($this->metadata as $key=>$value) |
|
| 1839 | - $this->_put('/'.$key.' '.$this->_textstring($value)); |
|
| 1840 | -} |
|
| 1980 | + foreach($this->metadata as $key=>$value) { |
|
| 1981 | + $this->_put('/'.$key.' '.$this->_textstring($value)); |
|
| 1982 | + } |
|
| 1983 | + } |
|
| 1841 | 1984 | |
| 1842 | 1985 | protected function _putcatalog() |
| 1843 | 1986 | { |
| 1844 | 1987 | $n = $this->PageInfo[1]['n']; |
| 1845 | 1988 | $this->_put('/Type /Catalog'); |
| 1846 | 1989 | $this->_put('/Pages 1 0 R'); |
| 1847 | - if($this->ZoomMode=='fullpage') |
|
| 1848 | - $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); |
|
| 1849 | - elseif($this->ZoomMode=='fullwidth') |
|
| 1850 | - $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); |
|
| 1851 | - elseif($this->ZoomMode=='real') |
|
| 1852 | - $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); |
|
| 1853 | - elseif(!is_string($this->ZoomMode)) |
|
| 1854 | - $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); |
|
| 1855 | - if($this->LayoutMode=='single') |
|
| 1856 | - $this->_put('/PageLayout /SinglePage'); |
|
| 1857 | - elseif($this->LayoutMode=='continuous') |
|
| 1858 | - $this->_put('/PageLayout /OneColumn'); |
|
| 1859 | - elseif($this->LayoutMode=='two') |
|
| 1860 | - $this->_put('/PageLayout /TwoColumnLeft'); |
|
| 1861 | -} |
|
| 1990 | + if($this->ZoomMode=='fullpage') { |
|
| 1991 | + $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); |
|
| 1992 | + } elseif($this->ZoomMode=='fullwidth') { |
|
| 1993 | + $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); |
|
| 1994 | + } elseif($this->ZoomMode=='real') { |
|
| 1995 | + $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); |
|
| 1996 | + } elseif(!is_string($this->ZoomMode)) { |
|
| 1997 | + $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); |
|
| 1998 | + } |
|
| 1999 | + if($this->LayoutMode=='single') { |
|
| 2000 | + $this->_put('/PageLayout /SinglePage'); |
|
| 2001 | + } elseif($this->LayoutMode=='continuous') { |
|
| 2002 | + $this->_put('/PageLayout /OneColumn'); |
|
| 2003 | + } elseif($this->LayoutMode=='two') { |
|
| 2004 | + $this->_put('/PageLayout /TwoColumnLeft'); |
|
| 2005 | + } |
|
| 2006 | + } |
|
| 1862 | 2007 | |
| 1863 | 2008 | protected function _putheader() |
| 1864 | 2009 | { |
@@ -1894,8 +2039,9 @@ discard block |
||
| 1894 | 2039 | $this->_put('xref'); |
| 1895 | 2040 | $this->_put('0 '.($this->n+1)); |
| 1896 | 2041 | $this->_put('0000000000 65535 f '); |
| 1897 | - for($i=1;$i<=$this->n;$i++) |
|
| 1898 | - $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 2042 | + for($i=1;$i<=$this->n;$i++) { |
|
| 2043 | + $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 2044 | + } |
|
| 1899 | 2045 | // Trailer |
| 1900 | 2046 | $this->_put('trailer'); |
| 1901 | 2047 | $this->_put('<<'); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | " AND ". |
| 140 | 140 | $this->empresa->var2str(\date('Y-m-d', strtotime($this->hasta))); |
| 141 | 141 | } |
| 142 | - $tipo_pagada = ($pagada)?'TRUE':'FALSE'; |
|
| 142 | + $tipo_pagada = ($pagada) ? 'TRUE' : 'FALSE'; |
|
| 143 | 143 | $sql = "SELECT f.idfactura, f.numero2, f.vencimiento, lf.referencia, lf.descripcion, f.fecha, lf.pvpsindto, ". |
| 144 | 144 | "lf.dtopor, lf.pvptotal". |
| 145 | 145 | " FROM facturascli as f left join lineasfacturascli as lf ON (f.idfactura = lf.idfactura)". |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | foreach ($data as $l) { |
| 153 | 153 | $linea = (object) $l; |
| 154 | 154 | $linea->f_pago = $linea->fecha; |
| 155 | - $linea->dias_atraso = ($pagada)?0:$this->diasAtraso($linea->vencimiento, \date('d-m-Y')); |
|
| 155 | + $linea->dias_atraso = ($pagada) ? 0 : $this->diasAtraso($linea->vencimiento, \date('d-m-Y')); |
|
| 156 | 156 | if (in_array('tesoreria', $GLOBALS['plugins'], true)) { |
| 157 | 157 | //TO-DO |
| 158 | 158 | } |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | $cliente = $cli->get($codcliente); |
| 180 | 180 | if ($iddireccion !== '') { |
| 181 | 181 | foreach ($cliente->get_direcciones() as $dir) { |
| 182 | - if ($dir->id === (int)$iddireccion) { |
|
| 182 | + if ($dir->id === (int) $iddireccion) { |
|
| 183 | 183 | $dir->direccion = $nueva_direccion; |
| 184 | 184 | $dir->save(); |
| 185 | 185 | break; |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | return $iddireccion; |
| 189 | - } else { |
|
| 189 | + }else { |
|
| 190 | 190 | $dir = new direccion_cliente(); |
| 191 | 191 | $dir->direccion = $nueva_direccion; |
| 192 | 192 | $dir->codcliente = $codcliente; |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | public $procesado; |
| 37 | 37 | |
| 38 | 38 | public function __construct($t = FALSE) { |
| 39 | - parent::__construct('residentes_fact_prog_edificaciones','plugins/residentes'); |
|
| 40 | - if($t){ |
|
| 39 | + parent::__construct('residentes_fact_prog_edificaciones', 'plugins/residentes'); |
|
| 40 | + if ($t) { |
|
| 41 | 41 | $this->id = $t['id']; |
| 42 | 42 | $this->idprogramacion = $t['idprogramacion']; |
| 43 | 43 | $this->id_edificacion = $t['id_edificacion']; |
| 44 | 44 | $this->codcliente = $t['codcliente']; |
| 45 | 45 | $this->idfactura = $t['idfactura']; |
| 46 | 46 | $this->procesado = $this->str2bool($t['procesado']); |
| 47 | - }else{ |
|
| 47 | + }else { |
|
| 48 | 48 | $this->id = null; |
| 49 | 49 | $this->idprogramacion = null; |
| 50 | 50 | $this->id_edificacion = null; |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function install(){ |
|
| 57 | + public function install() { |
|
| 58 | 58 | return ""; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function exists() |
| 62 | 62 | { |
| 63 | - if(is_null($this->id)) { |
|
| 63 | + if (is_null($this->id)) { |
|
| 64 | 64 | return false; |
| 65 | 65 | } |
| 66 | 66 | return true; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function save() |
| 70 | 70 | { |
| 71 | - if($this->exists()){ |
|
| 71 | + if ($this->exists()) { |
|
| 72 | 72 | $sql = "UPDATE ".$this->table_name." SET ". |
| 73 | 73 | "idfactura = ".$this->intval($this->idfactura).", ". |
| 74 | 74 | "codcliente = ".$this->var2str($this->codcliente).", ". |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | "WHERE id = ".$this->intval($this->id).";"; |
| 79 | 79 | $data = $this->db->exec($sql); |
| 80 | 80 | return $data; |
| 81 | - } else { |
|
| 81 | + }else { |
|
| 82 | 82 | $sql = "INSERT INTO ".$this->table_name. |
| 83 | 83 | " (idprogramacion, id_edificacion, codcliente, procesado) VALUES (". |
| 84 | 84 | $this->intval($this->idprogramacion).", ". |
| 85 | 85 | $this->intval($this->id_edificacion).", ". |
| 86 | 86 | $this->var2str($this->codcliente).", ". |
| 87 | 87 | $this->var2str($this->procesado).");"; |
| 88 | - if($this->db->exec($sql)){ |
|
| 88 | + if ($this->db->exec($sql)) { |
|
| 89 | 89 | return true; |
| 90 | - }else{ |
|
| 90 | + }else { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $sql = "select * from ".$this->table_name." WHERE id = ".$this->intval($id); |
| 100 | 100 | $this->new_advice($sql); |
| 101 | 101 | $data = $this->db->select($sql); |
| 102 | - if($data) { |
|
| 102 | + if ($data) { |
|
| 103 | 103 | return new residentes_facturacion_programada_edificaciones($data[0]); |
| 104 | 104 | } |
| 105 | 105 | return false; |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | $sql = "select * from ".$this->table_name." WHERE idprogramacion = ".$this->intval($idProg)." ORDER BY id"; |
| 111 | 111 | $data = $this->db->select($sql); |
| 112 | 112 | $lista = array(); |
| 113 | - if($data) { |
|
| 114 | - foreach($data as $d) { |
|
| 113 | + if ($data) { |
|
| 114 | + foreach ($data as $d) { |
|
| 115 | 115 | $lista[] = new residentes_facturacion_programada_edificaciones($d); |
| 116 | 116 | } |
| 117 | 117 | return $lista; |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | " AND procesado = FALSE ORDER BY id"; |
| 126 | 126 | $data = $this->db->select($sql); |
| 127 | 127 | $lista = array(); |
| 128 | - if($data) { |
|
| 129 | - foreach($data as $d) { |
|
| 128 | + if ($data) { |
|
| 129 | + foreach ($data as $d) { |
|
| 130 | 130 | $lista[] = new residentes_facturacion_programada_edificaciones($d); |
| 131 | 131 | } |
| 132 | 132 | return $lista; |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | $sql = "select * from ".$this->table_name." WHERE idprogramacion = ".$this->intval($idProg)." ORDER BY id"; |
| 139 | 139 | $data = $this->db->select($sql); |
| 140 | 140 | $lista = array(); |
| 141 | - if($data) { |
|
| 142 | - foreach($data as $d) { |
|
| 141 | + if ($data) { |
|
| 142 | + foreach ($data as $d) { |
|
| 143 | 143 | $item = new residentes_facturacion_programada_edificaciones($d); |
| 144 | 144 | $this->infoAdicional($item); |
| 145 | 145 | $lista[] = $item; |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | ." AND "."estado = ".$this->var2str($status)." ORDER BY idprogramacion, id"; |
| 186 | 186 | $data = $this->db->select($sql); |
| 187 | 187 | $lista = array(); |
| 188 | - if($data) { |
|
| 189 | - foreach($data as $d) { |
|
| 188 | + if ($data) { |
|
| 189 | + foreach ($data as $d) { |
|
| 190 | 190 | $lista[] = new residentes_facturacion_programada_edificaciones($d); |
| 191 | 191 | } |
| 192 | 192 | return $lista; |
@@ -199,8 +199,8 @@ discard block |
||
| 199 | 199 | $sql = "select * from ".$this->table_name." ORDER BY idprogramacion, id"; |
| 200 | 200 | $data = $this->db->select($sql); |
| 201 | 201 | $lista = array(); |
| 202 | - if($data) { |
|
| 203 | - foreach($data as $d) { |
|
| 202 | + if ($data) { |
|
| 203 | + foreach ($data as $d) { |
|
| 204 | 204 | $lista[] = new residentes_facturacion_programada_edificaciones($d); |
| 205 | 205 | } |
| 206 | 206 | return $lista; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $sql = "DELETE from ".$this->table_name." WHERE id = ".$this->intval($this->id); |
| 214 | 214 | $data = $this->db->exec($sql); |
| 215 | - if($data) { |
|
| 215 | + if ($data) { |
|
| 216 | 216 | return true; |
| 217 | 217 | } |
| 218 | 218 | return false; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @author Joe Nilson <joenilson at gmail.com> |
| 24 | 24 | */ |
| 25 | -class residentes_ayudas extends \fs_model{ |
|
| 25 | +class residentes_ayudas extends \fs_model { |
|
| 26 | 26 | /** |
| 27 | 27 | * El codigo de la ayuda ya sea para parentesco u ocupacion |
| 28 | 28 | * @var string |
@@ -39,19 +39,19 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public $descripcion; |
| 41 | 41 | public function __construct($t = FALSE) { |
| 42 | - parent::__construct('residentes_ayudas','plugins/residentes'); |
|
| 43 | - if($t){ |
|
| 42 | + parent::__construct('residentes_ayudas', 'plugins/residentes'); |
|
| 43 | + if ($t) { |
|
| 44 | 44 | $this->codigo = $t['codigo']; |
| 45 | 45 | $this->tipo = $t['tipo']; |
| 46 | 46 | $this->descripcion = $t['descripcion']; |
| 47 | - }else{ |
|
| 47 | + }else { |
|
| 48 | 48 | $this->codigo = null; |
| 49 | 49 | $this->tipo = null; |
| 50 | 50 | $this->descripcion = null; |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function install(){ |
|
| 54 | + public function install() { |
|
| 55 | 55 | return "insert into residentes_ayudas (codigo,tipo, descripcion) VALUES ". |
| 56 | 56 | "('EMPPUB','OCUPACION','Empleado Publico'),". |
| 57 | 57 | "('EMPRI','OCUPACION','Empleado Privado'),". |
@@ -65,66 +65,66 @@ discard block |
||
| 65 | 65 | "('HIJO','PARENTESCO','HermanHijo (a)');"; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function all(){ |
|
| 68 | + public function all() { |
|
| 69 | 69 | $sql = "SELECT * FROM ".$this->table_name." ORDER BY tipo,codigo"; |
| 70 | 70 | $data = $this->db->select($sql); |
| 71 | - if($data){ |
|
| 71 | + if ($data) { |
|
| 72 | 72 | $lista = array(); |
| 73 | - foreach($data as $d){ |
|
| 73 | + foreach ($data as $d) { |
|
| 74 | 74 | $lista[] = new residentes_ayudas($d); |
| 75 | 75 | } |
| 76 | 76 | return $lista; |
| 77 | - }else{ |
|
| 77 | + }else { |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function all_tipo($tipo){ |
|
| 82 | + public function all_tipo($tipo) { |
|
| 83 | 83 | $sql = "SELECT * FROM ".$this->table_name." WHERE tipo = ".$this->var2str($tipo)." ORDER BY codigo"; |
| 84 | 84 | $data = $this->db->select($sql); |
| 85 | - if($data){ |
|
| 85 | + if ($data) { |
|
| 86 | 86 | $lista = array(); |
| 87 | - foreach($data as $d){ |
|
| 87 | + foreach ($data as $d) { |
|
| 88 | 88 | $lista[] = new residentes_ayudas($d); |
| 89 | 89 | } |
| 90 | 90 | return $lista; |
| 91 | - }else{ |
|
| 91 | + }else { |
|
| 92 | 92 | return false; |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function get($codigo,$tipo){ |
|
| 96 | + public function get($codigo, $tipo) { |
|
| 97 | 97 | $sql = "SELECT * FROM ".$this->table_name." WHERE codigo = ".$this->var2str($codigo)." AND tipo = ".$this->var2str($tipo).";"; |
| 98 | 98 | $data = $this->db->select($sql); |
| 99 | - if($data){ |
|
| 99 | + if ($data) { |
|
| 100 | 100 | return new residentes_ayudas($data[0]); |
| 101 | - }else{ |
|
| 101 | + }else { |
|
| 102 | 102 | return false; |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function exists() { |
| 107 | - if(is_null($this->codigo)){ |
|
| 107 | + if (is_null($this->codigo)) { |
|
| 108 | 108 | return false; |
| 109 | - }else{ |
|
| 110 | - return $this->get($this->codigo,$this->tipo); |
|
| 109 | + }else { |
|
| 110 | + return $this->get($this->codigo, $this->tipo); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | public function save() { |
| 115 | - if($this->exists()){ |
|
| 115 | + if ($this->exists()) { |
|
| 116 | 116 | $sql = "UPDATE ".$this->table_name." SET ". |
| 117 | 117 | "descripcion = ".$this->var2str($this->descripcion)." ". |
| 118 | 118 | "WHERE codigo = ".$this->var2str($this->codigo)." AND tipo = ".$this->var2str($this->tipo).";"; |
| 119 | 119 | return $this->db->exec($sql); |
| 120 | - }else{ |
|
| 120 | + }else { |
|
| 121 | 121 | $sql = "INSERT INTO ".$this->table_name." (codigo, tipo, descripcion) VALUES (". |
| 122 | 122 | $this->var2str($this->codigo).", ". |
| 123 | 123 | $this->var2str($this->tipo).", ". |
| 124 | 124 | $this->var2str($this->descripcion).");"; |
| 125 | - if($this->db->exec($sql)){ |
|
| 125 | + if ($this->db->exec($sql)) { |
|
| 126 | 126 | return $this->db->lastval(); |
| 127 | - }else{ |
|
| 127 | + }else { |
|
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @author Joe Nilson <joenilson at gmail.com> |
| 26 | 26 | */ |
| 27 | -class residentes_vehiculos extends \fs_model{ |
|
| 27 | +class residentes_vehiculos extends \fs_model { |
|
| 28 | 28 | /** |
| 29 | 29 | * El Id del vehiculo |
| 30 | 30 | * @var integer serial |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $this->vehiculo_placa = $t['vehiculo_placa']; |
| 81 | 81 | $this->vehiculo_tipo = $t['vehiculo_tipo']; |
| 82 | 82 | $this->codigo_tarjeta = $t['codigo_tarjeta']; |
| 83 | - } else { |
|
| 83 | + }else { |
|
| 84 | 84 | $this->idvehiculo = null; |
| 85 | 85 | $this->codcliente = null; |
| 86 | 86 | $this->vehiculo_marca = null; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $lista[] = $item; |
| 121 | 121 | } |
| 122 | 122 | return $lista; |
| 123 | - } else { |
|
| 123 | + }else { |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $data = $this->db->select($sql); |
| 133 | 133 | if ($data) { |
| 134 | 134 | return new residentes_vehiculos($data[0]); |
| 135 | - } else { |
|
| 135 | + }else { |
|
| 136 | 136 | return false; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function get_by_field($field, $value) |
| 147 | 147 | { |
| 148 | - $query = (is_string($value))?$this->var2str($value):$this->intval($value); |
|
| 148 | + $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value); |
|
| 149 | 149 | $sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query.";"; |
| 150 | 150 | $data = $this->db->select($sql); |
| 151 | 151 | if ($data) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $lista[] = $item; |
| 156 | 156 | } |
| 157 | 157 | return $lista; |
| 158 | - } else { |
|
| 158 | + }else { |
|
| 159 | 159 | return false; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | if (is_null($this->idvehiculo)) { |
| 166 | 166 | return false; |
| 167 | - } else { |
|
| 167 | + }else { |
|
| 168 | 168 | return $this->get($this->codcliente, $this->idvehiculo); |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | "WHERE idvehiculo = ".$this->intval($this->idvehiculo)." AND ". |
| 183 | 183 | "codcliente = ".$this->var2str($this->codcliente).";"; |
| 184 | 184 | return $this->db->exec($sql); |
| 185 | - } else { |
|
| 185 | + }else { |
|
| 186 | 186 | $sql = "INSERT INTO ".$this->table_name." (codcliente, vehiculo_marca, vehiculo_modelo, vehiculo_color, ". |
| 187 | 187 | "vehiculo_placa, vehiculo_tipo, codigo_tarjeta) VALUES (". |
| 188 | 188 | $this->var2str($this->codcliente).", ". |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $this->var2str($this->codigo_tarjeta).");"; |
| 195 | 195 | if ($this->db->exec($sql)) { |
| 196 | 196 | return $this->db->lastval(); |
| 197 | - } else { |
|
| 197 | + }else { |
|
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -209,17 +209,17 @@ discard block |
||
| 209 | 209 | $clilist = array(); |
| 210 | 210 | $query = mb_strtolower($this->no_html($busqueda), 'UTF8'); |
| 211 | 211 | |
| 212 | - $consulta = "SELECT * FROM " . $this->table_name . " WHERE "; |
|
| 212 | + $consulta = "SELECT * FROM ".$this->table_name." WHERE "; |
|
| 213 | 213 | if (is_numeric($query)) { |
| 214 | - $consulta .= "(codigo_tarjeta LIKE '%" . $query . "%' OR CAST(idvehiculo as CHAR) = '%" . $query . "%')"; |
|
| 215 | - } else { |
|
| 214 | + $consulta .= "(codigo_tarjeta LIKE '%".$query."%' OR CAST(idvehiculo as CHAR) = '%".$query."%')"; |
|
| 215 | + }else { |
|
| 216 | 216 | $buscar = str_replace(' ', '%', $query); |
| 217 | - $consulta .= "(lower(codigo_tarjeta) LIKE '%" . $buscar . |
|
| 218 | - "%' OR lower(vehiculo_color) LIKE '%" . $buscar . "%'" . |
|
| 219 | - " OR lower(vehiculo_marca) LIKE '%" . $buscar . |
|
| 220 | - "%' OR lower(vehiculo_modelo) LIKE '%" . $buscar . "%'" . |
|
| 221 | - " OR lower(vehiculo_placa) LIKE '%" . $buscar . |
|
| 222 | - "%' OR lower(vehiculo_tipo) LIKE '%" . $buscar . "%')"; |
|
| 217 | + $consulta .= "(lower(codigo_tarjeta) LIKE '%".$buscar. |
|
| 218 | + "%' OR lower(vehiculo_color) LIKE '%".$buscar."%'". |
|
| 219 | + " OR lower(vehiculo_marca) LIKE '%".$buscar. |
|
| 220 | + "%' OR lower(vehiculo_modelo) LIKE '%".$buscar."%'". |
|
| 221 | + " OR lower(vehiculo_placa) LIKE '%".$buscar. |
|
| 222 | + "%' OR lower(vehiculo_tipo) LIKE '%".$buscar."%')"; |
|
| 223 | 223 | } |
| 224 | 224 | $consulta .= " ORDER BY codcliente ASC"; |
| 225 | 225 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @author Joe Nilson <joenilson at gmail.com> |
| 26 | 26 | * @version 1 |
| 27 | 27 | */ |
| 28 | -class residentes_informacion extends \fs_model{ |
|
| 28 | +class residentes_informacion extends \fs_model { |
|
| 29 | 29 | /** |
| 30 | 30 | * Codigo del cliente |
| 31 | 31 | * @var string |
@@ -143,60 +143,60 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | parent::__construct('residentes_informacion', 'plugins/residentes'); |
| 145 | 145 | if ($t) { |
| 146 | - $this->codcliente=$t['codcliente']; |
|
| 147 | - $this->codigo=$t['codigo']; |
|
| 148 | - $this->ocupantes=$t['ocupantes']; |
|
| 149 | - $this->ocupantes5anos=$t['ocupantes5anos']; |
|
| 150 | - $this->ocupantes12anos=$t['ocupantes12anos']; |
|
| 151 | - $this->ocupantes18anos=$t['ocupantes18anos']; |
|
| 152 | - $this->ocupantes30anos=$t['ocupantes30anos']; |
|
| 153 | - $this->ocupantes50anos=$t['ocupantes50anos']; |
|
| 154 | - $this->ocupantes70anos=$t['ocupantes70anos']; |
|
| 155 | - $this->ocupantes71anos=$t['ocupantes71anos']; |
|
| 156 | - $this->informacion_discapacidad=$t['informacion_discapacidad']; |
|
| 157 | - $this->propietario=$this->str2bool($t['propietario']); |
|
| 158 | - $this->profesion=$t['profesion']; |
|
| 159 | - $this->ocupacion=$t['ocupacion']; |
|
| 160 | - $this->ca_nombres=$t['ca_nombres']; |
|
| 161 | - $this->ca_apellidos=$t['ca_apellidos']; |
|
| 162 | - $this->ca_telefono=$t['ca_telefono']; |
|
| 163 | - $this->ca_email=$t['ca_email']; |
|
| 164 | - $this->ca_propietario=$this->str2bool($t['ca_propietario']); |
|
| 165 | - $this->ca_parentesco=$t['ca_parentesco']; |
|
| 166 | - $this->ca_parentesco_obs=$t['ca_parentesco_obs']; |
|
| 167 | - $this->vehiculos=$t['vehiculos']; |
|
| 168 | - } else { |
|
| 169 | - $this->codcliente=NULL; |
|
| 170 | - $this->codigo=NULL; |
|
| 171 | - $this->ocupantes=NULL; |
|
| 172 | - $this->ocupantes5anos=NULL; |
|
| 173 | - $this->ocupantes12anos=NULL; |
|
| 174 | - $this->ocupantes18anos=NULL; |
|
| 175 | - $this->ocupantes30anos=NULL; |
|
| 176 | - $this->ocupantes50anos=NULL; |
|
| 177 | - $this->ocupantes70anos=NULL; |
|
| 178 | - $this->ocupantes71anos=NULL; |
|
| 179 | - $this->informacion_discapacidad=NULL; |
|
| 180 | - $this->propietario='FALSE'; |
|
| 181 | - $this->profesion=NULL; |
|
| 182 | - $this->ocupacion=NULL; |
|
| 183 | - $this->ca_nombres=NULL; |
|
| 184 | - $this->ca_apellidos=NULL; |
|
| 185 | - $this->ca_telefono=NULL; |
|
| 186 | - $this->ca_email=NULL; |
|
| 187 | - $this->ca_propietario='FALSE'; |
|
| 188 | - $this->ca_parentesco=NULL; |
|
| 189 | - $this->ca_parentesco_obs=''; |
|
| 190 | - $this->vehiculos=0; |
|
| 146 | + $this->codcliente = $t['codcliente']; |
|
| 147 | + $this->codigo = $t['codigo']; |
|
| 148 | + $this->ocupantes = $t['ocupantes']; |
|
| 149 | + $this->ocupantes5anos = $t['ocupantes5anos']; |
|
| 150 | + $this->ocupantes12anos = $t['ocupantes12anos']; |
|
| 151 | + $this->ocupantes18anos = $t['ocupantes18anos']; |
|
| 152 | + $this->ocupantes30anos = $t['ocupantes30anos']; |
|
| 153 | + $this->ocupantes50anos = $t['ocupantes50anos']; |
|
| 154 | + $this->ocupantes70anos = $t['ocupantes70anos']; |
|
| 155 | + $this->ocupantes71anos = $t['ocupantes71anos']; |
|
| 156 | + $this->informacion_discapacidad = $t['informacion_discapacidad']; |
|
| 157 | + $this->propietario = $this->str2bool($t['propietario']); |
|
| 158 | + $this->profesion = $t['profesion']; |
|
| 159 | + $this->ocupacion = $t['ocupacion']; |
|
| 160 | + $this->ca_nombres = $t['ca_nombres']; |
|
| 161 | + $this->ca_apellidos = $t['ca_apellidos']; |
|
| 162 | + $this->ca_telefono = $t['ca_telefono']; |
|
| 163 | + $this->ca_email = $t['ca_email']; |
|
| 164 | + $this->ca_propietario = $this->str2bool($t['ca_propietario']); |
|
| 165 | + $this->ca_parentesco = $t['ca_parentesco']; |
|
| 166 | + $this->ca_parentesco_obs = $t['ca_parentesco_obs']; |
|
| 167 | + $this->vehiculos = $t['vehiculos']; |
|
| 168 | + }else { |
|
| 169 | + $this->codcliente = NULL; |
|
| 170 | + $this->codigo = NULL; |
|
| 171 | + $this->ocupantes = NULL; |
|
| 172 | + $this->ocupantes5anos = NULL; |
|
| 173 | + $this->ocupantes12anos = NULL; |
|
| 174 | + $this->ocupantes18anos = NULL; |
|
| 175 | + $this->ocupantes30anos = NULL; |
|
| 176 | + $this->ocupantes50anos = NULL; |
|
| 177 | + $this->ocupantes70anos = NULL; |
|
| 178 | + $this->ocupantes71anos = NULL; |
|
| 179 | + $this->informacion_discapacidad = NULL; |
|
| 180 | + $this->propietario = 'FALSE'; |
|
| 181 | + $this->profesion = NULL; |
|
| 182 | + $this->ocupacion = NULL; |
|
| 183 | + $this->ca_nombres = NULL; |
|
| 184 | + $this->ca_apellidos = NULL; |
|
| 185 | + $this->ca_telefono = NULL; |
|
| 186 | + $this->ca_email = NULL; |
|
| 187 | + $this->ca_propietario = 'FALSE'; |
|
| 188 | + $this->ca_parentesco = NULL; |
|
| 189 | + $this->ca_parentesco_obs = ''; |
|
| 190 | + $this->vehiculos = 0; |
|
| 191 | 191 | } |
| 192 | 192 | $this->cliente = new cliente(); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public function install(){ |
|
| 195 | + public function install() { |
|
| 196 | 196 | return ""; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public function info_adicional($i){ |
|
| 199 | + public function info_adicional($i) { |
|
| 200 | 200 | $data = $this->cliente->get($i->codcliente); |
| 201 | 201 | $i->nombre = $data->nombre; |
| 202 | 202 | $i->telefono1 = $data->telefono1; |
@@ -206,17 +206,17 @@ discard block |
||
| 206 | 206 | return $i; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - public function all(){ |
|
| 209 | + public function all() { |
|
| 210 | 210 | $sql = "SELECT * FROM ".$this->table_name." ORDER BY codcliente"; |
| 211 | 211 | $data = $this->db->select($sql); |
| 212 | - if($data){ |
|
| 212 | + if ($data) { |
|
| 213 | 213 | $lista = array(); |
| 214 | - foreach($data as $d){ |
|
| 214 | + foreach ($data as $d) { |
|
| 215 | 215 | $item = new residentes_informacion($d); |
| 216 | 216 | $lista[] = $item->info_adicional($item); |
| 217 | 217 | } |
| 218 | 218 | return $lista; |
| 219 | - }else{ |
|
| 219 | + }else { |
|
| 220 | 220 | return false; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | * @param type $padre_tipo integer |
| 229 | 229 | * @return \FacturaScripts\model\residentes_informacion|boolean |
| 230 | 230 | */ |
| 231 | - public function get($codcliente){ |
|
| 231 | + public function get($codcliente) { |
|
| 232 | 232 | $sql = "SELECT * FROM ".$this->table_name. |
| 233 | 233 | " WHERE codcliente = ".$this->var2str($codcliente).";"; |
| 234 | 234 | $data = $this->db->select($sql); |
| 235 | - if($data){ |
|
| 235 | + if ($data) { |
|
| 236 | 236 | $item = new residentes_informacion($data[0]); |
| 237 | 237 | return $item->info_adicional($item); |
| 238 | - }else{ |
|
| 238 | + }else { |
|
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -246,32 +246,32 @@ discard block |
||
| 246 | 246 | * @param type $value string |
| 247 | 247 | * @return boolean|\FacturaScripts\model\residentes_informacion |
| 248 | 248 | */ |
| 249 | - public function get_by_field($field,$value){ |
|
| 250 | - $query = (is_string($value))?$this->var2str($value):$this->intval($value); |
|
| 249 | + public function get_by_field($field, $value) { |
|
| 250 | + $query = (is_string($value)) ? $this->var2str($value) : $this->intval($value); |
|
| 251 | 251 | $sql = "SELECT * FROM ".$this->table_name." WHERE ".strtoupper(trim($field))." = ".$query.";"; |
| 252 | 252 | $data = $this->db->select($sql); |
| 253 | - if($data){ |
|
| 253 | + if ($data) { |
|
| 254 | 254 | $lista = array(); |
| 255 | - foreach($data as $d){ |
|
| 255 | + foreach ($data as $d) { |
|
| 256 | 256 | $item = new residentes_informacion($d); |
| 257 | 257 | $lista[] = $item->info_adicional($item); |
| 258 | 258 | } |
| 259 | 259 | return $lista; |
| 260 | - }else{ |
|
| 260 | + }else { |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | public function exists() { |
| 266 | - if(!$this->get($this->codcliente)){ |
|
| 266 | + if (!$this->get($this->codcliente)) { |
|
| 267 | 267 | return false; |
| 268 | - }else{ |
|
| 268 | + }else { |
|
| 269 | 269 | return $this->get($this->codcliente); |
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | public function save() { |
| 274 | - if($this->exists()){ |
|
| 274 | + if ($this->exists()) { |
|
| 275 | 275 | $sql = "UPDATE ".$this->table_name." SET ". |
| 276 | 276 | "codigo = ".$this->var2str($this->codigo).", ". |
| 277 | 277 | "ocupantes = ".$this->intval($this->ocupantes).", ". |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | "vehiculos = ".$this->intval($this->vehiculos)." ". |
| 297 | 297 | "WHERE codcliente = ".$this->var2str($this->codcliente).";"; |
| 298 | 298 | return $this->db->exec($sql); |
| 299 | - }else{ |
|
| 299 | + }else { |
|
| 300 | 300 | $sql = "INSERT INTO ".$this->table_name." (codcliente, codigo, ocupantes, ocupantes5anos, ocupantes12anos, ocupantes18anos, ocupantes30anos, ocupantes50anos, ocupantes70anos, ocupantes71anos, informacion_discapacidad, propietario, profesion, ocupacion, ca_nombres, ca_apellidos, ca_telefono, ca_email, ca_propietario, ca_parentesco, ca_parentesco_obs, vehiculos) VALUES (". |
| 301 | 301 | $this->var2str($this->codcliente).", ". |
| 302 | 302 | $this->var2str($this->codigo).", ". |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | $this->var2str($this->ca_parentesco).", ". |
| 321 | 321 | $this->var2str($this->ca_parentesco_obs).", ". |
| 322 | 322 | $this->intval($this->vehiculos).");"; |
| 323 | - if($this->db->exec($sql)){ |
|
| 323 | + if ($this->db->exec($sql)) { |
|
| 324 | 324 | return true; |
| 325 | - }else{ |
|
| 325 | + }else { |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -336,14 +336,14 @@ discard block |
||
| 336 | 336 | $clilist = array(); |
| 337 | 337 | $query = mb_strtolower($this->no_html($busqueda), 'UTF8'); |
| 338 | 338 | |
| 339 | - $consulta = "SELECT * FROM " . $this->table_name . " WHERE "; |
|
| 339 | + $consulta = "SELECT * FROM ".$this->table_name." WHERE "; |
|
| 340 | 340 | if (is_numeric($query)) { |
| 341 | - $consulta .= "(ca_telefono LIKE '%" . $query . "%' OR codigo LIKE '%" . $query . "%')"; |
|
| 342 | - } else { |
|
| 341 | + $consulta .= "(ca_telefono LIKE '%".$query."%' OR codigo LIKE '%".$query."%')"; |
|
| 342 | + }else { |
|
| 343 | 343 | $buscar = str_replace(' ', '%', $query); |
| 344 | - $consulta .= "(lower(ca_nombres) LIKE '%" . $buscar . "%' OR lower(ca_apellidos) LIKE '%" . $buscar . "%'" |
|
| 345 | - . " OR lower(ocupacion) LIKE '%" . $buscar . "%' OR lower(profesion) LIKE '%" . $buscar . "%'" |
|
| 346 | - . " OR lower(ca_email) LIKE '%" . $buscar . "%')"; |
|
| 344 | + $consulta .= "(lower(ca_nombres) LIKE '%".$buscar."%' OR lower(ca_apellidos) LIKE '%".$buscar."%'" |
|
| 345 | + . " OR lower(ocupacion) LIKE '%".$buscar."%' OR lower(profesion) LIKE '%".$buscar."%'" |
|
| 346 | + . " OR lower(ca_email) LIKE '%".$buscar."%')"; |
|
| 347 | 347 | } |
| 348 | 348 | $consulta .= " ORDER BY codcliente ASC"; |
| 349 | 349 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $lista[] = $item->info_adicional($item); |
| 217 | 217 | } |
| 218 | 218 | return $lista; |
| 219 | - }else{ |
|
| 219 | + } else{ |
|
| 220 | 220 | return false; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | if($data){ |
| 236 | 236 | $item = new residentes_informacion($data[0]); |
| 237 | 237 | return $item->info_adicional($item); |
| 238 | - }else{ |
|
| 238 | + } else{ |
|
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $lista[] = $item->info_adicional($item); |
| 258 | 258 | } |
| 259 | 259 | return $lista; |
| 260 | - }else{ |
|
| 260 | + } else{ |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | public function exists() { |
| 266 | 266 | if(!$this->get($this->codcliente)){ |
| 267 | 267 | return false; |
| 268 | - }else{ |
|
| 268 | + } else{ |
|
| 269 | 269 | return $this->get($this->codcliente); |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | "vehiculos = ".$this->intval($this->vehiculos)." ". |
| 297 | 297 | "WHERE codcliente = ".$this->var2str($this->codcliente).";"; |
| 298 | 298 | return $this->db->exec($sql); |
| 299 | - }else{ |
|
| 299 | + } else{ |
|
| 300 | 300 | $sql = "INSERT INTO ".$this->table_name." (codcliente, codigo, ocupantes, ocupantes5anos, ocupantes12anos, ocupantes18anos, ocupantes30anos, ocupantes50anos, ocupantes70anos, ocupantes71anos, informacion_discapacidad, propietario, profesion, ocupacion, ca_nombres, ca_apellidos, ca_telefono, ca_email, ca_propietario, ca_parentesco, ca_parentesco_obs, vehiculos) VALUES (". |
| 301 | 301 | $this->var2str($this->codcliente).", ". |
| 302 | 302 | $this->var2str($this->codigo).", ". |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $this->intval($this->vehiculos).");"; |
| 323 | 323 | if($this->db->exec($sql)){ |
| 324 | 324 | return true; |
| 325 | - }else{ |
|
| 325 | + } else{ |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | } |